Hi, everyone.
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
Use the "ESC" key
- gambafeliz
- Posts: 141
- Joined: Friday 2nd September 2022 7:50pm
- Location: I live in the same city as Picasso
Use the "ESC" key
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
- BruceSteers
- Posts: 1599
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Use the "ESC" key
Public Sub Form_KeyPress()
Select Key.Code
Case Key.Esc
' your code here
End Select
End
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- gambafeliz
- Posts: 141
- Joined: Friday 2nd September 2022 7:50pm
- Location: I live in the same city as Picasso
Re: Use the "ESC" key
I knew about this option but it is not good to use it. I need to associate it with a button. maybe it's not possible?
thank you
thank you
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
- BruceSteers
- Posts: 1599
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Use the "ESC" key
so how are you using Alt+V as the shortcut for a button?
maybe make a menu item that does the same function and set the shortcut in the menu editor?
maybe make a menu item that does the same function and set the shortcut in the menu editor?
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- gambafeliz
- Posts: 141
- Joined: Friday 2nd September 2022 7:50pm
- Location: I live in the same city as Picasso
Re: Use the "ESC" key
Thank you
How do I do it? Would you be so kind as to give me an example?
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.
- BruceSteers
- Posts: 1599
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Use the "ESC" key
What show how to make a menu item in the IDE?gambafeliz wrote: ↑Wednesday 1st November 2023 8:28am Thank you
How do I do it? Would you be so kind as to give me an example?
er, hit the "Menu editor" button
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- gambafeliz
- Posts: 141
- Joined: Friday 2nd September 2022 7:50pm
- Location: I live in the same city as Picasso
Re: Use the "ESC" key
Okay, sorry, I thought it was about something else.
Thanks for everything.
Thanks for everything.
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Use the "ESC" key
If I read this correctly, you need to look at the Button properties of Default and Cancel. To get a Button to respond to a key press add a '&' before a letter in the Text property. In the example below [Alt]+O, [Alt]+C, [Esc] and [Return] will all 'Press' a Button.
Run the following code in a new graphical project: -
Run the following code in a new graphical project: -
' Gambas class file
hPanel As Panel
hBox1 As HBox
ButtonOK As Button
ButtonCancel As Button
Spring1 As Spring
LabelInfo As Label
LabelMessage As Label
Timer1 As Timer
Public Sub ButtonOK_Click()
LabelMessage.Text = "OK pressed"
Timer1.Start
End
Public Sub ButtonCancel_Click()
LabelMessage.Text = "Cancel pressed"
Timer1.Start
End
Public Sub Form_Open()
With Me
.height = 200
.Width = 350
.Padding = 5
.Arrangement = Arrange.Vertical
End With
hPanel = New Panel(Me)
hPanel.Height = 10
With LabelInfo = New Label(Me)
.Height = 28
.Alignment = Align.Center
.Font.Bold = True
.Font.Size = 14
.Text = "Press 'Esc' or 'Enter' or click a button"
End With
hPanel = New Panel(Me)
hPanel.Height = 10
With hBox1 = New HBox(Me)
.Padding = 10
.Height = 50
.Width = 50
End With
With ButtonOK = New Button(hBox1) As "ButtonOK"
.Width = 112
.Height = 28
.Default = True ''Here is the property you need
.Text = "&OK"
End With
Spring1 = New Spring(hBox1)
With ButtonCancel = New Button(hBox1) As "ButtonCancel"
.Width = 112
.Height = 28
.Cancel = True ''Here is the property you need
.Text = "&Cancel"
End With
hPanel = New Panel(Me)
hPanel.Height = 50
With LabelMessage = New Label(Me) As "LabelMessage"
.Height = 28
.Width = 100
.Alignment = Align.Center
.Font.Bold = True
.Font.Size = 14
End With
Timer1 = New Timer As "Timer1"
Timer1.Delay = 2000
End
Public Sub Timer1_Timer()
LabelMessage.Text = ""
Timer1.Stop
End
- gambafeliz
- Posts: 141
- Joined: Friday 2nd September 2022 7:50pm
- Location: I live in the same city as Picasso
Re: Use the "ESC" key
You have left me impressed. Yes, that's what I'm looking for. Thank you.
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.
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.
- gambafeliz
- Posts: 141
- Joined: Friday 2nd September 2022 7:50pm
- Location: I live in the same city as Picasso
Re: Use the "ESC" key
Ok
Property:
.Cancel = True (ESC)
Thank you
Property:
.Cancel = True (ESC)
Thank you
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.