Keypress on a Form
Posted
#1
(In Topic #507)
Enthusiast

I am new to Gambas and I have been trying to get a example program to print a message to a label when I press F1 but I can not get it to work
This is the code behind the form
Public Sub Form_Open
'
End
Public Sub Form_KeyPress
If Key.F1 Then LCDLabel2.text = Time & " F1 Key Pressed"
End
I am use to using VB6 and VB.net but in them languages I had to set the Form keypreview to true but i can not see that option in Gambas.
Can someone please help me as I have big plans for this app.
Also can I ask iof Gambas supports MDI application development?
Posted
Regular

Code (gambas)
- ShiftPressed = False
- Speed = 1
- UpdateLabels()
- ' another one
- 'Main keyboard returns Return and Keypad is Enter
- TextBox1.Text = "Enter"
- The Key Code Program
- The Code
- The Key Release Program
- The Code
- Textbox1.Text = "Left"
- Textbox1.Text = "Right"
- Textbox1.Text = "Up"
- Textbox1.Text = "Down"
- Input Restrictions
- Example
- Example2
- You can reach nearly the same With the following code:
Hope that helps. Yes Gambas does do MDI just not quite like VB did. Take a look at my Handyman program in the showcase section of the site. It uses Gambas MDI.
Posted
Guru

Here is my input to your question.
Code (gambas)
- ''All the Properies here can be made in the IDE
- .Height = 150
- .Width = 900
- .Padding = 5
- .Arrangement = Arrange.Fill
- With LCDLabel2
- .Alignment = Align.Center
- .Padding = 20
- .Background = Color.Black
- .Foreground = Color.Black
- .HighlightColor = Color.Green
- 'If Key.F1 Then LCDLabel2.text = Time & " F1 Key Pressed"
<IMG src="https://www.cogier.com/gambas/Time%20-%20F1.png">
</IMG>
Posted
Guru

An alternative way would be if you have set up a menu item (use the menu editor) that does the job and simply Set the F1 shortcut key on it.
Posted
Enthusiast

THank you for the replay I have to change it to a GTK+ application and now it works
Is there such a thing as a MDI application in gambas? (i can do do a MDI in VB.net) I ask as I want to transfer my Windows application
into Linux and I use multiple forms to create the look I want for the app
Posted
Regular

1 guest and 0 members have just viewed this.


