Editable ComboBoxGadget

Just starting out? Need help? Post your questions and find answers here.
jak64
Enthusiast
Enthusiast
Posts: 639
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Editable ComboBoxGadget

Post by jak64 »

Good morning,
I've been looking for 2 hours and I can't find the solution!!!
I have an editable ComboBoxGadget.

I retrieve text fine when I type characters.

What I can't do is detect if it's the ENTER key that I'm typing, which would mean that I've finished typing and I could add this element to the ComboBoxGadget!

I tested several Eventypes, used KeyBoardDown, queried ChatGPT... without correct results...

It should perhaps be easy but here, I'm stuck...

Thank you for your help

Code: Select all

      If GadgetID = Combo_Themes
        Select EventType()
          Case #PB_EventType_Change
            Combo_Themes_Saisie = GetGadgetText(Combo_Themes)
            Debug Combo_Themes_Saisie
        EndSelect 
      EndIf
jak64
Enthusiast
Enthusiast
Posts: 639
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: Editable ComboBoxGadget

Post by jak64 »

Good morning,
I just found a solution by adding a keyboard shortcut (with the number 10) for the Enter key.

When I press the Enter key, I check that it is indeed my Combo which has the focus and, if so, I call a procedure in which I will do the update.

Code: Select all

AddKeyboardShortcut(#Fenetre_Windows_Principale,#PB_Shortcut_Return,10) ;= Numéro de l'évènement (entre 0 et 64000)

Code: Select all

      ;=====
      ;===== Raccourci clavier pour détecter si la touche Entrée est appuyée
      ;=====
      Case #PB_Event_Menu
        Select EventMenu()
          Case 10
            ;= Vérifier si c'est la Combo Thèmes qui a le menu
            If GetActiveGadget() = Combo_Themes
              ;= Ajouter le thème saisi dans la Combo Thèmes
              Ajouter_Theme_Dans_Combo_Theme()
            EndIf
      EndSelect

Code: Select all

      ;=====
      ;===== Combo Thèmes
      ;=====
      If GadgetID = Combo_Themes
        Select EventType()
          Case #PB_EventType_Change
            ;= Récupérer le texte saisi dans la Combo lorsqu'on saisit un caractère au clavier
            Combo_Themes_Saisie = GetGadgetText(Combo_Themes)
            ;= Tester si le dernier caractère saisi est la touche Entrée
        EndSelect 
      EndIf
Post Reply