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

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


On Thu, 22 Jan 2026 at 00:02, Benoît Minisini <
benoit.minisini@xxxxxxxxxxxxxxxx> wrote:

> Le 22/01/2026 à 00:54, Bruce Steers a écrit :
> >
> >
> >
> > On Wed, 21 Jan 2026 at 23:21, Benoît Minisini <benoit.minisini@gambas-
> > basic.org <mailto:benoit.minisini@xxxxxxxxxxxxxxxx>> wrote:
> >
> >     Le 21/01/2026 à 23:39, Bruce Steers a écrit :
> >      >
> >      >
> >      > On Wed, 21 Jan 2026, 21:54 Bruce Steers, <bsteers4@xxxxxxxxx
> >     <mailto:bsteers4@xxxxxxxxx>
> >      > <mailto:bsteers4@xxxxxxxxx <mailto:bsteers4@xxxxxxxxx>>> wrote:
> >      >
> >      >
> >      >
> >      >                 You should pass it directly what you get from
> >      >                 'Key.Shortcut'.
> >      >
> >      >
> >      >     The only big bug in that program is i realised Key.Shortcut
> >     letter
> >      >     text is always upper case.
> >      >
> >      >
> >      > I guess this upper case issue is a bug then?
> >
> >     Sort of.
> >
> >     Internally "a" and "A" have different key values.
> >
> >     The problem is that on the keyboard it's written "A", whereas the
> >     key is
> >     actually "a", and you have to use SHIFT to get an "A".
> >
> >     So Qt returns the code "A" when you press "A" or "a", as well as GTK+
> >     where I add to do a conversion for that.
> >
> >
> > I'm not sure i explained properly.
> >
> > The new Key.Send function "should" only send lower case if no Shift is
> > present
> > So
> > Key.Send("a")
> > Key.Send("A")
> > should both send lower case "a" because of no Shift+
> > Respectively
> > Key.Send("Shift+a")
> > Key.Send("Shift+A")
> > Key.Send("SHIFT+A")
> > should all send upper case "A"
> >
> > The case of the Key.Shortcut string or what's used in Key.Send() command
> > should be irrelevant and only an upper case letter sent if Shift+ is
> > present.
> >
> >
> >     I have to implement the reverse trick when interpreting the shortcut
> >     passed to 'Key.Send()', otherwise there is no coherency.
> >
> >
> > Is it not a simple as sending the text as upper or lower case depending
> > on the Shift+ being true
> >
> > Currently i get this result...
> >    Key.Send("Shift+a")
> >    Key.Send("Shift+A")
> >    Key.Send("a")
> >    Key.Send("A")
> >
> > aAaA
> >
> > but it should be AAaa
> > The case is being controlled by what ever case the text sent is and not
> > by the presence of Shift+
> >
> > I don't know the c++ code but i think that all the converting you need
> > is to convert any letter to lower case if no Shift+ and upper if there is
> >
> > Respects
> > BruceS
> >
>
> It's more complex than that, because not everybody has the same keyboard
> layout.
>
> It's what I said: "A" and "a" are two different keys in the toolkit
> logic, whereas they are not on american and french keyboard (and
> others), and so does the shortcut representation, which is then no
> coherent anymore with 'Key.Code'.
>
> --
> Benoît Minisini.


My simple gambas fix is this...

     sShortCut = If(sShortcut Like "*shift+*", Upper(sShortcut),
Lower(sShortcut))
    Key.Send(sShortcut)

It seems Key.Send() is case insensitive to the modifiers so i can send the
whole string as either upper or lower then the letter is correct.

I've made auto-inherited Key.class and added this...

Static Public Sub Send(Shortcut As String)

  Dim aStr As String[]
  Dim sCut As String

  If Shortcut.Len > 1 Then
    aStr = Split(Shortcut, ";", Null, True)
    If aStr.Count > 1 Then
      For Each sCut In aStr
        If sCut Ends "Space" Then sCut = Replace(sCut, "Space", " ",
gb.Like)
        sCut = If(sCut Like "*shift+*", Upper(sCut), Lower(sCut))
        Super.Send(sCut)
      Next
      Return
    Endif
  Endif

  sCut = = Shortcut
  If sCut Ends "Space" Then sCut = Replace(sCut, "Space", " ", gb.Like)
  sCut = If(sCut Like "*shift+*", Upper(sCut), Lower(sCut))
  Super.Send(sCut)

End

Works as expected like that on gtk and qt. the whole string is converted to
upper or lower depending if shift+ is present.

also i can send multiple keys separated by ;
Eg.
Key.Send("Shift+I;';M;Space;Shift+H;A;P;P;Y")
I'm Happy

Respects
BruceS

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>
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>
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>