Check the event: SplitterGadget release (Win/Mac)
Check the event: SplitterGadget release (Win/Mac)
I search for an Event like "Release the mouse button after moving a slider of a SplitterGadget" to reload some things...
Re: Check the event: SplitterGadget release (Win/Mac)
For macOS is only one event and check only the last position of splitter gadget.
For window check messages.
Update
- Bugfix Gadget Number
For window check messages.
Update
- Bugfix Gadget Number
Code: Select all
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
Protected Gadget
Select uMsg
Case #WM_CAPTURECHANGED
Gadget = GetProp_(hWnd, "PB_ID")
If GadgetType(Gadget) = #PB_GadgetType_Splitter
PostEvent(#PB_Event_Gadget, GetActiveWindow(), Gadget, #PB_EventType_Change)
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 0, 0, 230, 195, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
#Button1 = 0
#Button2 = 1
#Splitter = 2
ButtonGadget(#Button1, 0, 0, 0, 0, "Button 1") ; es besteht keine Notwendigkeit, die Größe oder Position
ButtonGadget(#Button2, 0, 0, 0, 0, "Button 2") ; festzulegen, da sie automatisch in der Größe angepasst werden
SplitterGadget(#Splitter, 5, 5, 220, 120, #Button1, #Button2, #PB_Splitter_Separator)
TextGadget(3, 10, 135, 210, 55, "Obiger GUI-Abschnitt zeigt zwei sich - innerhalb des 220x120 SplitterGadget Bereichs - automatisch in der Größe anpassende Schalter.", #PB_Text_Center)
LastPostion = GetGadgetState(#Splitter)
SetWindowCallback(@WinCallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case #Splitter
If EventType() = #PB_EventType_Change
If LastPostion <> GetGadgetState(#Splitter)
Debug "Splitter Position = " + GetGadgetState(#Splitter)
LastPostion = GetGadgetState(#Splitter)
EndIf
EndIf
EndSelect
EndSelect
ForEver
EndIf
Last edited by mk-soft on Sun Feb 16, 2020 3:07 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Check the event: SplitterGadget release (Win/Mac)
Check Splitter
(example based on help example)
Case #PB_Event_Gadget
If EventGadget() = #Splitter
Edit: mk-soft beat me to it with a roughly similar solution.
(I didn't use a callback, because I still don't understand much of it. )
Edit: But that may not completely answer your problem, I don't detect the "mouse release" but the movement of the splitter.
(example based on help example)
Case #PB_Event_Gadget
If EventGadget() = #Splitter
Code: Select all
OpenWindow(0, 0, 0, 230, 180, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
#Button1 = 0
#Button2 = 1
#Splitter = 2
ButtonGadget(#Button1, 0, 0, 0, 0, "Button 1")
ButtonGadget(#Button2, 0, 0, 0, 0, "Button 2")
SplitterGadget(#Splitter, 5, 5, 220, 120, #Button1, #Button2, #PB_Splitter_Separator)
TextGadget(3, 10, 135, 210, 40, "Move splitter",#PB_Text_Center )
Repeat
Select WaitWindowEvent(0)
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
If EventGadget() = #Splitter
Debug "Height B1:" +GadgetHeight(#Button1) + " B2:" + GadgetHeight(#Button2)
EndIf
EndSelect
Until WaitWindowEvent() = #PB_Event_CloseWindow
(I didn't use a callback, because I still don't understand much of it. )
Edit: But that may not completely answer your problem, I don't detect the "mouse release" but the movement of the splitter.
Re: Check the event: SplitterGadget release (Win/Mac)
+1Lebostein wrote:I search for an Event like "Release the mouse button after moving a slider of a SplitterGadget" to reload some things...
When using a splitter gadget with background color, it often happens that one pixel row is not colored after moving the splitter.
Currently I get the #WM_LBUTTONUP event from Windows and redraw the gadget one time again.
sorry for my bad english
Re: Check the event: SplitterGadget release (Win/Mac)
Update
- Bugfix Gadget Number
Small bug fixes
P.S.
MSDN Info
- Bugfix Gadget Number
Small bug fixes
P.S.
MSDN Info
Link: https://docs.microsoft.com/en-us/window ... urechangedWM_CAPTURECHANGED message
- Sent to the window that is losing the mouse capture.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Check the event: SplitterGadget release (Win/Mac)
Update
Now with SetGadgetCallback and the event 'WM_LBUTTONUP'
Update Module v0.03
- Remove Map and Mutex
- Change to Properties
Now with SetGadgetCallback and the event 'WM_LBUTTONUP'
Update Module v0.03
- Remove Map and Mutex
- Change to Properties
Code: Select all
;-TOP
; Comment : Module SetGadgetCallback (Windows Only)
; Author : mk-soft
; Version : v0.03
; Created : 10.06.2018
; Updated : 16.02.2020
; Link : https://www.purebasic.fr/english/viewtopic.php?f=12&t=70842
;
; Syntax Callback:
; Procedure GadgetCB(hWnd,uMsg,wParam,lParam)
; Select uMsg
; ;TODO
; EndSelect
; ; Call previous gadget procedure
; ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
; EndProcedure
;
; *****************************************************************************
DeclareModule GadgetCallback
Declare SetGadgetCallback(Gadget, *lpNewFunc)
Declare CallGadgetProc(hWnd, uMsg, wParam, lParam)
EndDeclareModule
Module GadgetCallback
EnableExplicit
; ---------------------------------------------------------------------------
Procedure SetGadgetCallback(Gadget, *lpNewFunc)
Protected hWnd, *lpPrevFunc
hWnd = GadgetID(Gadget)
*lpPrevFunc = GetProp_(hWnd, "PB_PrevFunc")
; Remove exists Callback
If *lpPrevFunc
SetWindowLongPtr_(hWnd, #GWL_WNDPROC, *lpPrevFunc)
RemoveProp_(hWnd, "PB_PrevFunc")
EndIf
; Set new Callback
If *lpNewFunc
*lpPrevFunc = SetWindowLongPtr_(hWnd, #GWL_WNDPROC, *lpNewFunc)
SetProp_(hWnd, "PB_PrevFunc", *lpPrevFunc)
ProcedureReturn *lpPrevFunc
EndIf
ProcedureReturn 0
EndProcedure
; ---------------------------------------------------------------------------
Procedure CallGadgetProc(hWnd, uMsg, wParam, lParam)
Protected result, *lpPrevFunc
*lpPrevFunc = GetProp_(hWnd, "PB_PrevFunc")
If *lpPrevFunc
result = CallWindowProc_(*lpPrevFunc, hWnd, uMsg, wParam, lParam)
EndIf
ProcedureReturn result
EndProcedure
EndModule
; *****************************************************************************
CompilerIf #PB_Compiler_IsMainFile
UseModule GadgetCallback
Procedure SplitterGadgetCB(hWnd, uMsg, wParam, lParam)
Protected Gadget
Select uMsg
Case #WM_LBUTTONUP
Gadget = GetProp_(hWnd, "PB_ID")
PostEvent(#PB_Event_Gadget, GetActiveWindow(), Gadget, #PB_EventType_LeftButtonUp)
EndSelect
ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
EndProcedure
If OpenWindow(0, 0, 0, 230, 195, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
#Button1 = 0
#Button2 = 1
#Splitter = 2
ButtonGadget(#Button1, 0, 0, 0, 0, "Button 1") ; es besteht keine Notwendigkeit, die Größe oder Position
ButtonGadget(#Button2, 0, 0, 0, 0, "Button 2") ; festzulegen, da sie automatisch in der Größe angepasst werden
SplitterGadget(#Splitter, 5, 5, 220, 120, #Button1, #Button2, #PB_Splitter_Separator)
TextGadget(3, 10, 135, 210, 55, "Obiger GUI-Abschnitt zeigt zwei sich - innerhalb des 220x120 SplitterGadget Bereichs - automatisch in der Größe anpassende Schalter.", #PB_Text_Center)
LastPostion = GetGadgetState(#Splitter)
SetGadgetCallback(#Splitter, @SplitterGadgetCB())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case #Splitter
If EventType() = #PB_EventType_LeftButtonUp
If LastPostion <> GetGadgetState(#Splitter)
Debug "Splitter Position = " + GetGadgetState(#Splitter)
LastPostion = GetGadgetState(#Splitter)
EndIf
EndIf
EndSelect
EndSelect
ForEver
EndIf
CompilerEndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Check the event: SplitterGadget release (Win/Mac)
Seems not correct. If I release a SplitterGadget on Mac OS, PureBasic spitts out hundrets of events one after the other...mk-soft wrote:For macOS is only one event and check only the last position of splitter gadget.
With this little example:
Code: Select all
OpenWindow(0, 0, 0, 230, 180, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
#Button1 = 0
#Button2 = 1
#Splitter = 2
ButtonGadget(#Button1, 0, 0, 0, 0, "Button 1")
ButtonGadget(#Button2, 0, 0, 0, 0, "Button 2")
SplitterGadget(#Splitter, 5, 5, 220, 120, #Button1, #Button2, #PB_Splitter_Separator)
TextGadget(3, 10, 135, 210, 40, "Move splitter",#PB_Text_Center )
Repeat
Select WaitWindowEvent(0)
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
If EventGadget() = #Splitter
Debug "Height B1:" +GadgetHeight(#Button1) + " B2:" + GadgetHeight(#Button2)
EndIf
EndSelect
Until WaitWindowEvent() = #PB_Event_CloseWindow
Every pixel change while moving the slider produces a #PB_Event_Gadget. And all these "collected in silence" events squirt out if I release the mouse....Height B1:56 B2:55
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Height B1:83 B2:28
Re: Check the event: SplitterGadget release (Win/Mac)
Yes, that why I have added this:With this little example:
...
Every pixel change while moving the slider produces a #PB_Event_Gadget. And all these "collected in silence" events squirt out if I release the mouse....
But the events are not collected, they only come up here because we ask for the display by Debug.Edit: But that may not completely answer your problem, I don't detect the "mouse release" but the movement of the splitter.
In Windows programming, hundreds of events are posted every second, we just process only the ones we need.
The Debug command slows down (a lot) a program, but all these displays are ignored after compilation.
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Check the event: SplitterGadget release (Win/Mac)
Not better, just different - when dealing with specific gadgets, I prefer the subclass approach shown here:
Code: Select all
; Windows only
; Avoids PB internals which are subject to change (and they do all the time)
#Button1 = 0
#Button2 = 1
#Splitter = 2
Procedure SplitterProc(hWnd, msg, wParam, lParam)
Static oldpos = -1, oldproc
If oldpos = -1
oldpos=GetGadgetState(#Splitter)
oldproc = GetProp_(hwnd, "oldproc")
EndIf
Select msg
Case #WM_LBUTTONUP
currentpos= GetGadgetState(#Splitter)
If currentpos<>oldpos
Debug "Handle position change from " + oldpos + " to " + currentpos
oldpos = currentpos
EndIf
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hWnd, msg, wParam, lParam)
EndProcedure
OpenWindow(0, 0, 0, 230, 195, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#Button1, 0, 0, 0, 0, "Button 1") ; es besteht keine Notwendigkeit, die Größe oder Position
ButtonGadget(#Button2, 0, 0, 0, 0, "Button 2") ; festzulegen, da sie automatisch in der Größe angepasst werden
SplitterGadget(#Splitter, 5, 5, 220, 120, #Button1, #Button2, #PB_Splitter_Separator)
TextGadget(3, 10, 135, 210, 55, "Obiger GUI-Abschnitt zeigt zwei sich - innerhalb des 220x120 SplitterGadget Bereichs - automatisch in der Größe anpassende Schalter.", #PB_Text_Center)
SetProp_(GadgetID(#Splitter), "oldproc", SetWindowLongPtr_(GadgetID(#Splitter), #GWL_WNDPROC, @SplitterProc()))
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
BERESHEIT
Re: Check the event: SplitterGadget release (Win/Mac)
My module SetGadgetCallback does nothing else.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Check the event: SplitterGadget release (Win/Mac)
@Lebostein
Its work with PB v5.71 and macOS Catalina Version 10.15.3 with one event
With which version of PB and macOS?Seems not correct. If I release a SplitterGadget on Mac OS, PureBasic spitts out hundrets of events one after the other...
Its work with PB v5.71 and macOS Catalina Version 10.15.3 with one event
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive