Get / set cursor position in SpinGadget
Posted: Mon Jun 15, 2020 2:59 pm
Is it possible to get and set the cursor position in a SpinGadget? I've only seen examples for a StringGadget so far, and they don't seem applicable.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure setCaretPos(gadID,Pos)
SendMessage_(gadID, #EM_SETSEL,Pos,Pos)
EndProcedure
If OpenWindow(0, 0, 0, 400, 300, "SpinGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SpinGadget (0, 10, 10, 80, 25, 0, 100,#PB_Spin_Numeric )
eHwnd = GetWindow_(GadgetID(0),#GW_HWNDFIRST)
SetGadgetState(0,100)
ButtonGadget(1,10,260,100,25,"Set Caret")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_LBUTTONDOWN
If GetActiveGadget() = 0
GetCaretPos_(p.POINT)
Pos = SendMessage_(eHwnd,#EM_CHARFROMPOS,0,p\y<<16+p\x)
Debug pos
EndIf
Case #PB_Event_Gadget
Select EventGadget()
Case 0
GetCaretPos_(p.POINT)
Pos = SendMessage_(eHwnd,#EM_CHARFROMPOS,0,p\y<<16+p\x)
Debug pos
Case 1
SetActiveGadget(0)
setCaretPos(eHwnd,2)
EndSelect
EndSelect
Until Quit = 1
EndIf