Page 1 of 1
Detect Control or Alt key from the passed event
Posted: Fri Apr 05, 2019 3:00 pm
by arfgh
so guys.. i have a doubt.. how to detect control key, or alt from the passed event ?
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 5:25 pm
by UnklDonald418
arfgh
how to detect control key, or alt from the passed event ?
in the example
FJCC posted, the XRAY results show
Which indicates that in addition the the A key, the Shift Key was also pressed.
https://www.openoffice.org/api/docs/com ... ifier.html
Because the Modifiers property is a bit mask, had the results showed
then both the Shift and Ctrl keys were pressed (1 + 2)
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 5:32 pm
by arfgh
ok, other doubt... how to detect same from a control that has no input text capabilities from user ? example a label control.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 6:16 pm
by UnklDonald418
arfgh
how to detect same from a control that has no input text capabilities from user ? example a label control.
makes no sense. A control that has no user input capabilities will never trigger a
Key pressed event.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 6:22 pm
by arfgh
UnklDonald418 wrote:arfgh
how to detect same from a control that has no input text capabilities from user ? example a label control.
makes no sense. A control that has no user input capabilities will never trigger a
Key pressed event.
friend, make sense when you want to have an alternate macro programming for a label control acting as ....hyperlink. When click without control button this, when click with control button, that. So should exist a way to do it.....
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 6:54 pm
by UnklDonald418
A control that has no user input capabilities will never see a Key Pressed event.
A label control will respond to Mouse events. Those events do have the same Modifier properties as Key pressed events.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 7:44 pm
by arfgh
I know, I know UnklDonald418, for that reason is asked... but see what i want to do... what way or what solutions we can take ? The easy way was just what i thought... if control is pressed this, and that if not. But the events are on labels... Surely exist some way to do it, or something that acts near....
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 11:07 pm
by UnklDonald418
A label control also has When receiving focus and When losing focus events, but it will never respond to those either.
Object oriented programming is based on inheritance and code reuse so perhaps they share some code with the Mouse events.
Maybe Mouse inside uses code from When receiving focus and Mouse outside uses code from When losing focus.
Likewise Mouse button pressed and Mouse button released are similar to Key pressed and Key released events.
Only a developer would know for sure.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Fri Apr 05, 2019 11:13 pm
by arfgh
and is there a way to listen for global* keypress event other than the event is listening ?
Re: [Solved] Macro: What key is pressed in key down event
Posted: Sat Apr 06, 2019 1:09 am
by JeJe
I presume we're talking about dialogs.
You get label control keypress events the same way: create a macro eg
sub label_keypressed(oevt)
msgbox oevt.keycode 'oevt.keychar 'oevt.modifiers
end sub
And assign the key pressed event to that macro.
If you want the label to receive the keypresses then use
dlg.getcontrol("Label1").setfocus
If you want one sub for all your keypress events then make sure just one control always keeps the focus... set tab index to 0 and tab stop to all the other controls to false... and use setfocus to that control if any of the other controls gain the focus.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Sat Apr 06, 2019 1:19 am
by Villeroy
Simply assign the event you are interested in to macro My_Macros>MriLib>Module1>MRI
It shows you everything about the event including the source object.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Sat Apr 06, 2019 4:57 pm
by UnklDonald418
Or assign a hot-key at Tools>Customize>Keyboard
Re: [Solved] Macro: What key is pressed in key down event
Posted: Sun Apr 07, 2019 1:01 am
by arfgh
that hot-key is a possible way but... i dont want to split in two subroutines... just only that detects control key pressed or not.. It's more proper, isnt it ?
Re: [Solved] Macro: What key is pressed in key down event
Posted: Sun Apr 07, 2019 4:07 am
by UnklDonald418
In Base if the macro is assigned to the hot key Ctrl+F9, only that key combination will trigger the macro.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Sun Apr 07, 2019 8:36 pm
by JeJe
I'm really not following what you want to do, but as you're on windows you can use the windows api to test whether the control key is down. Put this code in a module, run it, and press the control key. It will run forever if you don't press the control key.
Code: Select all
Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
sub checkforControlkeyDown
do
If GetAsyncKeyState( &h11) Then
msgbox "ctrl pressed"
exit do
end if
loop
End Sub
Re: [Solved] Macro: What key is pressed in key down event
Posted: Sun Apr 07, 2019 9:06 pm
by arfgh
that was what i was thinking these days... if we can use win32 api in our macros....
Re: [Solved] Macro: What key is pressed in key down event
Posted: Tue Apr 09, 2019 4:21 pm
by arfgh
JeJe wrote:I'm really not following what you want to do, but as you're on windows you can use the windows api to test whether the control key is down. Put this code in a module, run it, and press the control key. It will run forever if you don't press the control key.
Code: Select all
Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
sub checkforControlkeyDown
do
If GetAsyncKeyState( &h11) Then
msgbox "ctrl pressed"
exit do
end if
loop
End Sub
Anyways that tip was amazing and works like a charm. But i cant understand the reason to limit key events depending on the controls. Because for example imagine the follow: we have an image control and we want to maximize it when move the mouse over it, but only when we have control key pressed. That example make sense a lot... but i figure that image control doesnt throw key event like label one....
Re: [Solved] Macro: What key is pressed in key down event
Posted: Tue Apr 09, 2019 7:04 pm
by Villeroy
Once again: This is NOT a development suite for database solutions. It is an office suite with a download size of less than 200 MB, including all the components and 2 macro languages, help files and a database engine. The form controls were made in the 90ies (StarOffice 5?) and did not change since then.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Tue Apr 09, 2019 7:39 pm
by arfgh
I dont care Villeroy, At the moment i have seen how it is possible to achieve all kind of solutions, and with each update, AOO works better and better.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Tue Apr 09, 2019 8:23 pm
by Villeroy
Which updates are you talking about? OpenOffice has not been updated significantly since many years.
P.S: latest Base features added in 2012:
https://wiki.openoffice.org/wiki/Base/N ... res_in_3_4
Re: [Solved] Macro: What key is pressed in key down event
Posted: Tue Apr 09, 2019 9:45 pm
by UnklDonald418
we have an image control and we want to maximize it when move the mouse over it, but only when we have control key pressed
Add this near the beginning of you image resize macro to check for the Ctrl key
Code: Select all
REM use AND to also capture Ctrl key modifier combinations
if (oEv.Modifiers AND com.sun.star.awt.KeyModifier.MOD1) = 0 then
exit sub
end if
Link your resize macro to a
Mouse moved event on an image control.
Now move the mouse cursor over the image and press the
Ctrl key to resize the image.
If you also want to be able to hold down the
Ctrl key and then move the mouse cursor over the image control, add a link to the
Mouse inside event .
Re: [Solved] Macro: What key is pressed in key down event
Posted: Tue Apr 09, 2019 10:23 pm
by Villeroy
Since 6 years we write all the macros for this idiot. He does not understand any hints until you explicitly tell him what to do exactly.
Re: [Solved] Macro: What key is pressed in key down event
Posted: Thu Apr 11, 2019 12:43 pm
by arfgh
Villeroy wrote:Since 6 years we write all the macros for this idiot. He does not understand any hints until you explicitly tell him what to do exactly.
idiot ? the most probable is that i kick ass you totally on other kind of programming languages. The reason that you seem an expert with AOO api dont make you a wise man... in fact who is the idiot ? the idiot or the idiot that call others idiot ?
have a nice day Mr. wiseman.