[Solved] Macro: What key is pressed in key down event

Creating a macro - Writing a Script - Using the API

[Solved] Macro: What key is pressed in key down event

Postby mark_orion » Thu Jun 25, 2009 10:20 am

I want to write a macro that gets triggered by a "key down" event and reacts depending on what key has been pressed. The "key down" part is easy as the events property of the form control has it, but how do I get the information about WHAT key is down ?
Last edited by mark_orion on Fri Jun 26, 2009 4:36 pm, edited 1 time in total.
OOo 2.4.X on Ubuntu 8.x
mark_orion
 
Posts: 38
Joined: Thu Oct 02, 2008 11:53 am

Re: Macro needs to know what key is pressed in key down event

Postby FJCC » Thu Jun 25, 2009 5:40 pm

I made a text box and set it to trigger a macro on "key down". The macro expected to be passed a parameter oEv. Here is the Macro

Code: Select all   Expand viewCollapse view
Sub Main(oEv)
xray oEv

End Sub


When I pressed Shift- A I got this from xray

Code: Select all   Expand viewCollapse view
KeyChar                   char                        "A"   
KeyCode                   integer                     512   
KeyFunc                   integer                       0   
Modifiers                 integer                       1   
Source                    object                           


So oEv.KeyChar is one way to find out what key was pressed.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7751
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Macro needs to know what key is pressed in key down event

Postby mark_orion » Fri Jun 26, 2009 4:35 pm

FJCC wrote:I made a text box and set it to trigger a macro on "key down". The macro expected to be passed a parameter oEv. Here is the Macro
So oEv.KeyChar is one way to find out what key was pressed.

Works excellent - thank you!
OOo 2.4.X on Ubuntu 8.x
mark_orion
 
Posts: 38
Joined: Thu Oct 02, 2008 11:53 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests