Cor Nouws wrote:
Hi Hal,
Hal Vaughan wrote (17-7-2008 21:15)
I've got a couple more questions and both are regarding keypresses.
1) Is there any way that a macro can wait on a keypress without using
a prompt or anything like that? For example, the macro may active
when F4 is pressed, then wait for the next keypress, find out what
key was pressed, and act on that? I've tried looking through API
docs, but I'm not sure what I'd use to listen to the keyboard.
Not so much experience with this. But have you looked at this one:
http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/Events
Yuck, this is not a fun area in my opinion. If you can make it happen
sufficiently fast, you can
Map your special key such as F4 to call your macro.
Have key F4 macro install a keyboard handler.
Your keyboard handler would intercept your ONE key.
While handling that one key, first remove the handler, then do the extra
work that you desire to do.
I think that AndrewMacro has a simple XKeyHandler example, but I would
need to check.
2) When I create dialog boxes for Basic, I'm running into a problem
with calling macros on events from controls. If I have a push
button, I can bind an action to mouse button released and it works
fine, but if I also bind it to key released, then it'll call that
macro even if I'm just tabbing through the controls -- once tab is
released, if that button has focus, the key release macro is called.
So far I've gotten around this by creating boolean variables for each
button and using two routines, one for key press and one for key up.
I set the variable to true on key press and on key up/released I
check and if the variable isn't true, I don't execute the bound macro.
Via the UI I bind events to "When initiating". And that works fine for
button type Default. So try that one.
Yes, this is correct.
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]