[Gambas-user] How to Change Keyboard Layout

Gianluigi bagonergi at gmail.com
Fri Oct 5 15:05:33 CEST 2018


Hi Fabien,
I confess to having bluffed, I do not know how to set up and calls with
SendKeys: Super_L+Space, by default on Ubuntu Bionic to switch layout. ;-D
Maybe we should ask the user of the program to set himself the keyboard
shortcut for example on CTRL+ALT+K and some other (simple) similar
alternative, what do you think?

Regards
Gianluigi

Il giorno ven 5 ott 2018 alle ore 06:41 Fabien Bodard <gambas.fr at gmail.com>
ha scritto:

> In fact as the switching dépend of the desktop it os not easily portable
> to other desktop... it s a quite hard coded thing. You will need to add a
> config option to your program to allow final user to adapt it to its
> current desktop shortcut.
>
> Le jeu. 4 oct. 2018 23:00, Gianluigi <bagonergi at gmail.com> a écrit :
>
>> With activated gb.desktop component:
>>
>> Private $bArabian As Boolean
>>
>> Public Sub Form_Open()
>>
>>   Dim s As String
>>   Dim hTxt As TextBox
>>
>>   hTxt = New TextBox(Me)
>>   hTxt.Foreground = Color.Transparent
>>   hTxt.SetFocus
>>   Me.Show
>>   Wait 0.1
>>   ' This combination works with the Italian layout and not with the
>> American one.
>>   ' You must find a combination suitable for Arabic.
>>   Desktop.SendKeys("{[Shift_L]6}")
>>   Wait 0.1
>>   s = hTxt.Text
>>   hTxt.Delete
>>   If s = "&" Then
>>     $bArabian = True
>>     Print "Arabian keyboard"
>>   Else
>>     $bArabian = False
>>     Print "American keyboard"
>>   Endif
>>   Print $bArabian
>>
>> End
>>
>> Public Sub txtArabian_GotFocus()
>>   ' I don't remember your shortcut to switch keyboard layout, supposing
>> Ctrl+K
>>   If $bArabian = False Then
>>     Desktop.SendKeys("{[Control_L]K}")
>>     $bArabian = True
>>   Endif
>>
>> End
>>
>> Public Sub txtAmerican_GotFocus()
>>   ' I don't remember your shortcut to switch keyboard layout, supposing
>> Ctrl+K
>>   If $bArabian Then
>>     Desktop.SendKeys("{[Control_L]K}")
>>     $bArabian = False
>>   Endif
>>
>> End
>>
>> Public Sub Form_KeyPress()
>>
>>   If Key.Code = Key["K"] And If Key.Control Then
>>     Print "SWITCH KEYBOARD"
>>   End If
>>
>> End
>>
>> Regards
>> Gianluigi
>>
>> Il giorno gio 4 ott 2018 alle ore 21:41 Wael M via User <
>> user at lists.gambas-basic.org> ha scritto:
>>
>>> Thanks Gianluigi and thanks Lee
>>> you both put some solutions that seems brilliant but I got confused and
>>> couldn't get an appropriate code out of those
>>> is my fault I know but don't forget I'm new to Gambas
>>> so if you please could send me an example for a forum with two textboxes
>>> each one changes the keyboard language when it get focus, I will be
>>> profoundly appreciated
>>>
>>> thanks again for your valuable time
>>>
>>> --------------------------------------------
>>> On Thu, 10/4/18, T Lee Davidson <t.lee.davidson at gmail.com> wrote:
>>>
>>>  Subject: Re: [Gambas-user] How to Change Keyboard Layout
>>>  To: user at lists.gambas-basic.org
>>>  Date: Thursday, October 4, 2018, 3:08 PM
>>>
>>>  If each box will use a specific
>>>  layout, you could use a semaphore.
>>>
>>>  [code]
>>>  Public $IsEnglishLayout
>>>  = True
>>>
>>>  Public Sub
>>>  EnglishTextbox1_GotFocus()
>>>    If Not
>>>  $IsEnglishLayout then Destkop.Sendkeys(blah)
>>>    $IsEnglishLayout = True
>>>  End
>>>
>>>  Public Sub
>>>  ArabicTextbox1_GotFocus()
>>>    If
>>>  $IsEnglishLayout then Destkop.Sendkeys(blah)
>>>    $IsEnglishLayout = False
>>>  End
>>>  [/code]
>>>
>>>
>>>  ___
>>>  Lee
>>>
>>>
>>>  On 10/3/18 5:27 PM, Wael M
>>>  via User wrote:
>>>  > Thank you very much
>>>  Gianluigi for your help, grazie :)
>>>  > it
>>>  worked and could detect my language but not the way I
>>>  want
>>>  > let me tell you my story :)
>>>  > I came to linux from windows and I'm
>>>  trying to translate an app I did with VB to the
>>>  corresponding codes in Gambas.
>>>  > I
>>>  realized that Gambas is not the same as VB because Linux is
>>>  not the same as windows
>>>  > Gambas is just
>>>  using the same names and following the main rules of VB
>>>  > in my app I had a form that with three
>>>  textboxes are filled in Arabic and three are filled in
>>>  English
>>>  > when I put the cursor in a
>>>  textbox it detects the keyboard layout and change it to the
>>>  desired language
>>>  > I followed the code
>>>  you gave but I want to put the event of this code to be when
>>>  textbox got focus
>>>  > here is the problem,
>>>  when I put cursor in the desired textbox, it evokes the code
>>>  and losing the focus the focus again the textbox making it
>>>  evoking the same code again and so on
>>>  >
>>>  so what I really need is to detect the keyboard layout like
>>>  reading it directly from linux
>>>  >
>>>  > again and again thank you very much for
>>>  your patience and help
>>>
>>>  ----[ Gambas mailing-list is hosted by https://www.hostsharing.net
>>> ]----
>>>
>>>
>>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>>
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181005/03b052d9/attachment.html>


More information about the User mailing list