Page 1 of 1

Textgadget with history of entries?

Posted: Sun Mar 26, 2023 11:06 pm
by matalog
Is there a gadget or a way to use Textgadget, that will result in it remembering the last few entries and allowing them to be accessed via a dropdown selection area?

Like when you click on a text entry area in a web browser, this commonly happens, letting you quickly choose something that you have entered previously.

Re: Textgadget with history of entries?

Posted: Sun Mar 26, 2023 11:30 pm
by idle
Combobox ?

Code: Select all

If OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
  AddGadgetItem(0, -1, "ComboBox 0")
  AddGadgetItem(0, -1, "ComboBox 1")
  AddGadgetItem(0, -1, "ComboBox 2")
  SetGadgetState(0, 2)
  Repeat : Until WaitWindowEvent()= #PB_Event_CloseWindow
EndIf


Re: Textgadget with history of entries?

Posted: Mon Mar 27, 2023 11:57 am
by spikey
Idle got there first, but with edits too...

Code: Select all

#KbdReturn = 1

Define.S Entry

If OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
  AddGadgetItem(0, -1, "Historical item 1")
  AddGadgetItem(0, -1, "Historical item 2")
  AddGadgetItem(0, -1, "Historical item 3")
  
  SetGadgetState(0, 0)
  
  AddKeyboardShortcut(0, #PB_Shortcut_Return, #KbdReturn)
  
  Repeat : 
    Event = WaitWindowEvent()
    If Event = #PB_Event_Menu And EventMenu() = #KbdReturn
      Entry = GetGadgetText(0)
      AddGadgetItem(0, 0, Entry)
      SetGadgetState(0, 0)
    EndIf
    
  Until Event = #PB_Event_CloseWindow
EndIf

Re: Textgadget with history of entries?

Posted: Mon Mar 27, 2023 4:08 pm
by AZJIO
viewtopic.php?t=79076

But I don't understand how to do it in the main menu. It is necessary to generate a list and attach the generated menu to a certain item of the main menu.

Re: Textgadget with history of entries?

Posted: Mon Mar 27, 2023 10:08 pm
by matalog
Great, thanks guys, sorted now.