[Gambas-user] is it possible to non-virtualize Key.class

Bruce Steers bsteers4 at gmail.com
Thu Mar 23 21:00:08 CET 2023


Could it be possible to non-virtualize Key.class ?

I tried to make a Key.class and added variables for the properties and a
way to have it either give the usual Key data or the set data.

The hope was i could set the variables then trigger a KeyPress event of an
object and it could read the fake details.

But it failed with "no Keyboard event data"

Could it be possible to manually set Key properties then trigger an event?

I am once again designing a Keystroke macro recorder for TextEditor.
Only this time I am not using x11.SendKey as it fails on wayland and sucks
on qt.

The easiest way i can see to do it would be to fake Key.class and then run
the TextEditors View_KeyPress() event.

below is the code that failed, it's incomplete (only handling
Ctrl,Shift,Alt modifiers) as it didn't seem to work anyway..

Respects

BruceS

[code]  Key.class

Static Property Read Control As Boolean
Static Private $bControl As Boolean
Static Property Read Shift As Boolean
Static Private $bShift As Boolean
Static Property Read Alt As Boolean
Static Private $bAlt As Boolean
Static Property Read Text As String
Static Private $sText As String

Static Property Read Code As Integer
Static Private $iCode As Integer

Static $bUseFake As Boolean

Static Public Sub ClearFakeCode()

  $bUseFake = False

End

Static Public Sub FakeCode((code) As Integer, Optional (Text) As String,
Ctrl As Boolean, Shft As Boolean, Alt As Boolean)

  $iCode = code
  $sText = Text
  $bControl = Ctrl
  $bAlt = Alt
  $bShift = Shft
  $bUseFake = True

End

Static Private Function Code_Read() As Integer

  If $bUseFake Then Return $iCode
  Return Super.Code

End

Static Private Function Control_Read() As Boolean

  If $bUseFake Then Return $bControl
  Return Super.Control

End

Static Private Function Shift_Read() As Boolean

  If $bUseFake Then Return $bShift
  Return Super.Shift

End

Static Private Function Alt_Read() As Boolean

  If $bUseFake Then Return $bAlt
  Return Super.Alt

End
Static Private Function Text_Read() As String

  If $bUseFake Then Return $sText
  Return Super.Text

End

[/code]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230323/59f0539f/attachment.htm>


More information about the User mailing list