[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allow missing components (or detect them in project)


On Wed, 21 Jan 2026 at 17:01, Bruce Steers <bsteers4@xxxxxxxxx> wrote:

>
>
> On Wed, 21 Jan 2026 at 11:15, Bruce Steers <bsteers4@xxxxxxxxx> wrote:
>
>> Omg omg omg , Fantastic 😁
>>
>> I'll start testing it as soon as I finish work 😎
>>
>> Thank you so very much Benoit.
>>
>> A superb addition to the gui suite 😎
>>
>> Much respect
>> BruceS
>>
>> On Wed, 21 Jan 2026, 08:20 Benoît Minisini, <
>> benoit.minisini@xxxxxxxxxxxxxxxx> wrote:
>>
>>> Le 17/01/2026 à 17:48, Benoît Minisini a écrit :
>>> > Le 17/01/2026 à 16:59, Bruce Steers a écrit :
>>> >>
>>> >>     Why don't you just use an event observer to catch the keyboard
>>> >>     events on
>>> >>     the editor?
>>> >>
>>> >>     And in that cas which private variable would you need?
>>> >>
>>> >>     --     Benoît Minisini.
>>> >>
>>> >>
>>> >> It's not the getting of the event it's the giving.
>>> >>
>>> >
>>> > Ah, now I remember, we already talk about that. If I remember
>>> correctly,
>>> > I said that I should add a way inside the GUI component to inject a
>>> fake
>>> > keyboard event, so that you don't have to do any trick to make macros.
>>> >
>>> > Is there an issue tracker for that request? I don't think it's very
>>> > difficult to implement that. But of course the fake key event may be
>>> > available only locally, and for controls written in Gambas. I will
>>> see...
>>> >
>>> > Regards,
>>> >
>>>
>>> Hi,
>>>
>>> I have added 'Key.Send()' in the last commits, that send a fake keyboard
>>> event to the current active control (two actually, one 'KeyPress', and
>>> one 'KeyRelease').
>>>
>>> It takes a string shortcut as argument, something like that:
>>>
>>> Key.Send("A")
>>> Key.Send("é")
>>> Key.Send("CTRL+C")
>>> Key.Send("CTRL+ALT+DEL")
>>>
>>> You should pass it directly what you get from 'Key.Shortcut'.
>>>
>>> Normally, you should be able to get rid of a lot of hacks with that!
>>>
>>> Regards,
>>>
>>> --
>>> Benoît Minisini.
>>
>>
>
> My initial findings....
>
> IT'S AWESOME :)))  thank you soooo much :) 🙏🙏
>
> I just made a working keystroke recorder / playback for text editor in
> about 10 minutes :)
> Then spent a little of time adding some tweaks :)
>
> I have to handle menu shortcuts that we might want to use in the recorder
> but are part of the program not the editor itself as these keystrokes are
> hidden from the editor.  Observers are attached to the menus to register
> the shortcut when pressed and when played back the menu item is just
> clicked.
>
> No need for the MacroKey class or anything now i can just send a shortcut
> string via Key.class, lovely :)
>
> Attached is the simple test KeyRecorder enabled TextEditor i just made.
> (using only inheritance :)
> You can see here it works great:
> https://gambasgb.uk/Clips/simplescreenrecorder-keyrecorder.mkv
>
> I'll run it through some tests :)
>
> Amazing :)  you are a star :)
> Much respect
> BruceS
>


The only big bug in that program is i realised Key.Shortcut letter text is
always upper case.
So the Key.Shortcut for uppercae T is Shift+T and for lower case its just T
(but upper case)
So cannot just directly use the Key.shortcut as is, it needs a little
handling first.

Incorrect case is easily fixed by using the Key.Text for the shortcut
  If IsLetter(Key.Text) Then sShortcut = Left(Key.Shortcut, -1) & Key.Text

Also the Key.Shortcut "Space" does not input a Space with Key.Send("Space")
so i convert "Space" to " " (before the above fix)
   sShortcut = Key.Shortcut
   If sShortcut Ends "Space" Then sShortcut = Replace(sShortcut, "Space", "
", gb.Like)
   If IsLetter(Key.Text) Then sShortcut = Left(Key.Shortcut, -1) & Key.Text

Those are the only "quirks" i've found so far.
Loving it though :)

Now ANY text control can be controlled easily,
No need to see if you need a Pos property or Row/Column, Goto, etc ..  just
virtually send the keyboard method.

Say for example a ClearLine/Delete line command for ANY text input control.

Public Sub TextObjectDeleteLine(Obj as Object, Optional Delete as Boolean)

  Obj.SetFocus
  Key.Send("Home")  ' goto start
  Key.Send("Shift+End")  ' select till end
  Key.Send("Delete")  ' Clear the line
  if Delete Then Key.Send("Delete")  ' optional hit delete again to delete
the empty line

End

A stupid simple example maybe but essentially i see this as a really useful
new thing :)

Respects
BruceS

Follow-Ups:
Re: Allow missing components (or detect them in project)Bruce Steers <bsteers4@xxxxxxxxx>
References:
Allow missing components (or detect them in project)Bruce Steers <bsteers4@xxxxxxxxx>
Re: Allow missing components (or detect them in project)Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Allow missing components (or detect them in project)Bruce Steers <bsteers4@xxxxxxxxx>
Re: Allow missing components (or detect them in project)Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Allow missing components (or detect them in project)Bruce Steers <bsteers4@xxxxxxxxx>
Re: Allow missing components (or detect them in project)Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Allow missing components (or detect them in project)Bruce Steers <bsteers4@xxxxxxxxx>
Re: Allow missing components (or detect them in project)Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Allow missing components (or detect them in project)Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Allow missing components (or detect them in project)Bruce Steers <bsteers4@xxxxxxxxx>
Re: Allow missing components (or detect them in project)Bruce Steers <bsteers4@xxxxxxxxx>