Possible to add mouse click to string gadget?

Just starting out? Need help? Post your questions and find answers here.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Possible to add mouse click to string gadget?

Post by SkyManager »

Is it possible to add a mouse click event to the string gadget?
Last edited by SkyManager on Wed Sep 09, 2015 9:30 am, edited 1 time in total.
Tess
New User
New User
Posts: 6
Joined: Thu Sep 25, 2014 8:59 am

Re: Possible to add mouse click to text gadget?

Post 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.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Re: Possible to add mouse click to text gadget?

Post 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
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Possible to add mouse click to string gadget?

Post 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
Image
Image
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

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

Post by SkyManager »

Thanks a lot
Post Reply