A Double-click to StringGadget()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
C87
Enthusiast
Enthusiast
Posts: 176
Joined: Mon Jul 17, 2017 7:22 am
Location: Cotswolds England

A Double-click to StringGadget()

Post by C87 »

For consideration: a left-double-click to a StringGadget() allows the developer to give the user easy access to data or anything related to the StringGadget() selected. The Event can load a Procedure() and/or additional screen(s) without the need for a button or a menu
If it's falling over......just remember the computer is never wrong!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: A Double-click to StringGadget()

Post by netmaestro »

String gadgets always have a text gadget to identify them. From a conceptual standpoint I think it makes more sense to add the event to the textgadget rather than the string gadget. If the team would add a new style #PB_Text_Clickable that would provide all we need for this. Otherwise, in the meantime, we're stuck with:

Code: Select all

;             *** WINDOWS ONLY ***

Procedure WinProc(hWnd, Msg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents     
  Select Msg
    Case #WM_COMMAND 
      If lParam = GadgetID(0)
        If  wParam>>16 & $FFFF = #STN_DBLCLK
          Debug "Going to " + GetGadgetText(1) + " now..."
        EndIf
      EndIf
  EndSelect
  ProcedureReturn result
EndProcedure

If OpenWindow(0, 0, 0, 322, 205, "StringGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowCallback(@WinProc(), 0)
  TextGadget(0, 10, 10, 60,20,"Planet:", #SS_NOTIFY)
  StringGadget(1, 68,  10, 200, 20, "")
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
BERESHEIT
User avatar
C87
Enthusiast
Enthusiast
Posts: 176
Joined: Mon Jul 17, 2017 7:22 am
Location: Cotswolds England

Re: A Double-click to StringGadget()

Post by C87 »

Whilst that may be one solution netmaestro, I cannot see why a double-click cannot be on the StringGadget(). Or indeed, why not have one to the TextGadget() as well? I suppose I could use a ButtonGadget() as a label instead of a TextGadget() but why when there could be a better fix?

Additionally, to have a double-click to a CheckBoxGadget(), I find is occasionally useful. Sometimes I like to prevent a casual change to a CheckBox (not in PureB obviously, because I can't). When a screen is in edit mode it is so easy to tab into a Checkbox and press <Space> to amend it. Where I want to prevent a casual change, the CheckBox remains locked and I will require a double-click to set or unset. The action can then only be deliberate. I know that I could pop up an "Are you sure message?" but users who make a change intentionally and who aren't careless will be irritated with a series of popup prompts every time they amend a record.

I think it would be helpful if we had a double-click on StringGadget(), TextGadget(), EditorGadget( and CheckBoxGadget()...maybe there are others? After all we have Double-Click events in TreeGadget() . Why not have Right-Click Event options while we are at it?
If it's falling over......just remember the computer is never wrong!
Post Reply