« Congratulations to th… | Home | Background Color for … »

Tip of the day: Do Copy and Paste yourself in Xojo desktop app on Windows

On Windows in a Xojo project if you have no menu bar on a window, the usual shortcuts like Control-C won't work. But if you like to get copy & paste to work, you may just handle the Control key plus various shortcuts yourself. So here some code you can copy & paste to your project if you have a window where textfields don't do the shortcuts. Best may be to put it in a TextField subclass to have it working in multiple fields without duplicating the code a lot of times:

EventHandler Function KeyDown(Key As String) As Boolean #If TargetWindows Dim a As Integer = Asc(key) If Keyboard.ControlKey Then Select Case a Case 1 // Control-A Me.SelStart = 0 Me.SelLength = Len(Me.Text) Return True Case 3 // Control-C Dim cl As New Clipboard cl.SetText Me.SelText Return True Case 22 // Control-V Dim cl As New Clipboard Me.SelText = cl.Text Return True Case 24 // Control-X Dim cl As New Clipboard cl.SetText Me.SelText Me.SelText = "" Return True Else Return False // ignore? End Select End If #EndIf End EventHandler
If you have questions, please don't hesitate to contact us.
14 03 20 - 11:49