Use the "ESC" key
Posted
#1
(In Topic #1121)
Enthusiast

I have the following problem:
I created a "Back" button and use Alt+V to make it work with the keyboard.
My ideal would be "Back" or "Go Back" or "Abort" with the "ESC" key but I don't know how to do it directly for the same button.
What I want to do is use the "ESC" key to execute a Reparent type command or call a subroutine and return window control to the previous state.
Can anyone suggest me how to do it, if possible?
Thank you
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

Posted
Enthusiast

thank you
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

maybe make a menu item that does the same function and set the shortcut in the menu editor?
Posted
Enthusiast

How do I do it? Would you be so kind as to give me an example?
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

gambafeliz said
Thank you
How do I do it? Would you be so kind as to give me an example?
What show how to make a menu item in the IDE?
er, hit the "Menu editor" button
Posted
Enthusiast

Thanks for everything.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

Run the following code in a new graphical project: -
Code (gambas)
- ' Gambas class file
- Spring1 As Spring
- LabelMessage.Text = "OK pressed"
- Timer1.Start
- LabelMessage.Text = "Cancel pressed"
- Timer1.Start
- .height = 200
- .Width = 350
- .Padding = 5
- .Arrangement = Arrange.Vertical
- .Height = 28
- .Alignment = Align.Center
- .Text = "Press 'Esc' or 'Enter' or click a button"
- .Padding = 10
- .Height = 50
- .Width = 50
- .Width = 112
- .Height = 28
- .Text = "&OK"
- .Width = 112
- .Height = 28
- .Text = "&Cancel"
- .Height = 28
- .Width = 100
- .Alignment = Align.Center
- Timer1.Delay = 2000
- LabelMessage.Text = ""
- Timer1.Stop
Posted
Enthusiast

But I promise you that I don't understand the mechanism to get a button to be pressed with "ESC" from the keyboard, even by reading your code. I'm even like the Indians in the tribes, when they say it's magic and I go to the corner afraid of what you've done.
Note: I would love some technical explanation about the mechanism, but, I'll leave it to you if you want.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Enthusiast

Property:
.Cancel = True (ESC)
Thank you
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
Posted
Guru

gambafeliz said
Ok
Property:
.Cancel = True (ESC)
Thank you
Indeed and in the same respect.
Property:
.Default = True (Return/Enter)
I hadn't thought of that.
That's actually a cool tip and something to think of in my applications to quickly set return or escape to a button <EMOJI seq="1f60e" tseq="1f60e">😎</EMOJI>
Cheers Charlie <EMOJI seq="1f60a" tseq="1f60a">😊</EMOJI>
Posted
Enthusiast

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
1 guest and 0 members have just viewed this.



