Page 1 of 1

Possible to add mouse click to string gadget?

Posted: Wed Sep 09, 2015 9:03 am
by SkyManager
Is it possible to add a mouse click event to the string gadget?

Re: Possible to add mouse click to text gadget?

Posted: Wed Sep 09, 2015 9:14 am
by Tess
Windows only:

Code: Select all

If OpenWindow(0,0,0,550,700,"TextGadget",#PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget) 
 
  TextGadget(0, 10, 10,250,20,"Clic me ",#SS_NOTIFY)
  
  Repeat 
    event=WaitWindowEvent(10) 
    Select event
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0 
            Debug "Surprise"  

        EndSelect
   
    EndSelect
  Until event=#PB_Event_CloseWindow
EndIf
You can also use an imagegadget or a canvasgadget or a disabled button, ... as a textgadget.

Tess.

Re: Possible to add mouse click to text gadget?

Posted: Wed Sep 09, 2015 9:29 am
by SkyManager
Tess,
Thank you for your quick reply.
Very sorry, I apologize for my mistake,
The correction is :
String gadget
It is just a typing mistake

Re: Possible to add mouse click to string gadget?

Posted: Wed Sep 09, 2015 10:05 am
by RSBasic

Code: Select all

EnableExplicit

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  StringGadget(1, 10, 10, 200, 20, "", 0)
  
  Repeat
    Select WaitWindowEvent()
      Case #WM_LBUTTONDOWN;or #WM_LBUTTONUP
        If GetActiveGadget() = 1
          Debug "Cick"
        EndIf
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
Or:

Code: Select all

EnableExplicit

Global StringProc

Procedure StringProc(hWnd, uMsg, wParam, lParam)
  Select uMsg
    Case #WM_LBUTTONDOWN;or #WM_LBUTTONUP
      Debug "Click"
  EndSelect
  
  ProcedureReturn CallWindowProc_(StringProc, hWnd, uMsg, wParam, lParam)
EndProcedure

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  StringGadget(1, 10, 10, 200, 20, "", 0)
  
  StringProc = SetWindowLongPtr_(GadgetID(1), #GWL_WNDPROC, @StringProc())
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

[solved] Possible to add mouse click to string gadget?

Posted: Thu Sep 10, 2015 8:43 am
by SkyManager
Thanks a lot