mouseclick with keypress
Posted
#1
(In Topic #996)
Trainee
How do I test the control key, when clicking on a row in a tableview. If CTRL-key is pressed then do this Else do that.
I can't find it on Internet or manuals.
Bert Steenhagen
Posted
Guru

Code (gambas)
Posted
Trainee
You have helped me well with your approach. I did it the other way around with the key-event
public CtrlPressed as boolean
Public Sub form_KeyPress()
If Key.ControlKey Then
CtrlPressed = True
Endif
End
Public Sub form_KeyRelease()
CtrlPressed = False
End
Public Sub mytable1_RowClick(Row As Integer)
If CtrlPressed = True Then
do_this
Else
do_the_other_thing
endif
End
Thank you so much,
Bert Steenhagen
Posted
Trainee
Public Sub form_KeyPress()
If Key.Control Then
CtrlPressed = True
Endif
End
Key.Control not Key.ControlKey
ControlKey is a constant (16777249), always TRUE !!
Bert Steenhagen
Posted
Guru

ControlKey is a constant (16777249), always TRUE !!
Be careful as this will change depending on whether you are using GTK or QT.
I quote here: -
Never compare the value of this property with a numeric constant, because the key codes may depend on the underlying toolkit.
Always use the constants defined in this class!
Posted
Guru

The properties are not valid in a Click() event but they are in a MouseUp and RowClick() event
Something like this will do the job….
Posted
Trainee
The better option.
Thanks for your tip
Bert Steenhagen
1 guest and 0 members have just viewed this.



