Hi!
I need enabling key down and mouse wheel handling for an owner drawn repeater gadget.
The repeater gadget is using container gadget.
I tried subclassing scrollbargadget which then is no more drawn.
I tried sub classing window; no way to get the message.
After subclassing window, I got once mouse wheel messages; after clicking somewhere, no more messages.
Next, I will see if a canvasgadget in the box behind the labels will work; but PB and z-index does often not work...
... o.k. "onClick" and canvas gets over the other elements...
... so next job is to see, how I can canvasgadget under the other gadgets again...
... even mousewheel over label works when canvas was once activated-> thats great!
Can someone please give me a hint how to handle this?
Thanks a lot.
[SOLVED];PB5.30; Win7; event handling; Canvas, Hide, Z-Index
[SOLVED];PB5.30; Win7; event handling; Canvas, Hide, Z-Index
Last edited by HanPBF on Fri May 22, 2015 10:59 am, edited 2 times in total.
Re: PB5.30; Win7; sublcass containergadget or scrollbargadge
Please post some simple example code so we can better understand the problem.
Re: PB5.30; Win7; sublcass containergadget or scrollbargadge
GOT IT: setting back the focus to the textbox after left click in canvas gadget is the "solution"; of course a focus problem with the canvasgadget (which has fortunately some more events than the other gadgets). Being able to put gadgets in Canvasgadget would be genius...
Here the example and the text before "GOT IT";-)
In the following code, the onWindowCallback proc does stop writing debug output after click on canvasgadget.
I wonder what I missed here...
Thanks!
Here the example and the text before "GOT IT";-)
In the following code, the onWindowCallback proc does stop writing debug output after click on canvasgadget.
I wonder what I missed here...
Code: Select all
Procedure.w MouseWheelDelta()
x.w = ((EventwParam()>>16)&$FFFF)
ProcedureReturn -(x / 120)
EndProcedure
Procedure onWindowCallback(WindowID, Msg, WParam, LParam)
if Msg=#WM_MOUSEWHEEL
debug "#WM_MOUSEWHEEL" ; does not work anymore after click on canvasgadget
endif
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,400,400,"Mouse Wheel", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
StringGadget(0,0,0,64,32,"0")
canvasgadget(1, 0, 48, 128, 200, #PB_Canvas_Keyboard)
SetWindowCallback(@onWindowCallback(), 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #WM_MOUSEWHEEL
SetGadgetText(0,Str(MouseWheelDelta()))
default
EndSelect
ForEver
Re: PB5.30; Win7; sublcass containergadget or scrollbargadge
You need to add the following to track the mousewheel when the canvas has focus:
Then add the following just after SetWindowCallback
Code: Select all
Procedure CanvasCallback()
Debug "#WM_MOUSEWHEEL with focus"
EndProcedure
Code: Select all
BindEvent(#PB_Event_Gadget, @CanvasCallback(), 0, 1, #PB_EventType_MouseWheel)
Re: PB5.30; Win7; subclass containergadget or scrollbargadge
Great, thanks a lot Julian!
Now I have the following situation:
- canvasgadget gets events as far as it is opened with #PB_Canvas_Keyboard -> o.k.
- using SetActiveGadget immed enables the receiving of events; no need for clicking on canvasgadget -> o.k.
- after clicking on canvasgadget it gets in the foreground -> problem
I've another post here in the forum asking for PB-Gadget/CanvasGadget into CanvasGadget; that could help me coming around the problem with z-index.
So, question now is how to get CanvasGadget back to background after click?
Thanks!
Hint; this works also and should be the same(?) as Julians' solution:
BindGadgetEvent(PBCanvasGadget, @onMouseWheelCanvasGadget(), #PB_EventType_MouseWheel)
Now I have the following situation:
- canvasgadget gets events as far as it is opened with #PB_Canvas_Keyboard -> o.k.
- using SetActiveGadget immed enables the receiving of events; no need for clicking on canvasgadget -> o.k.
- after clicking on canvasgadget it gets in the foreground -> problem
I've another post here in the forum asking for PB-Gadget/CanvasGadget into CanvasGadget; that could help me coming around the problem with z-index.
So, question now is how to get CanvasGadget back to background after click?
Thanks!
Hint; this works also and should be the same(?) as Julians' solution:
BindGadgetEvent(PBCanvasGadget, @onMouseWheelCanvasGadget(), #PB_EventType_MouseWheel)
Re: PB5.30; Win7; sublcass containergadget or scrollbargadge
I checked it with focus and lostfocus for canvasgadget.
The canvasgadget does only receive events when being the active gadget.
so far so good.
when it gets active, its coming up (z-index above / hiding other controls).
normal behaviour.
So I did:
Next thing to solve is flickering...
The canvasgadget does only receive events when being the active gadget.
so far so good.
when it gets active, its coming up (z-index above / hiding other controls).
normal behaviour.
So I did:
Code: Select all
declare sendGadgetBack(PBGadget)
Procedure onFocusCanvasGadget()
sendGadgetBack(EventGadget())
EndProcedure
Procedure onLostFocusCanvasGadget()
sendGadgetBack(EventGadget())
EndProcedure
Procedure sendGadgetBack(PBGadget)
hideGadget(PBGadget, #True)
hideGadget(PBGadget, #False)
SetActiveGadget(PBGadget)
EndProcedure
Re: PB5.30; Win7; sublcass containergadget or scrollbargadge
O.k. finally to complete this post...
got the list running with key down and up, page key down and up for scrollbar.
CanvasGadget was the solution to this.
No flickering anymore as I set backgrounds of container and canvas to same color.
Even with more complex background -> can get and set image with catchimage if needed:-)
It was important for me to got the bindgadgetevents working; using window callback or window event loop would have needed to keep track of current gadget to handle events for.
Thanks a lot, indeed!
got the list running with key down and up, page key down and up for scrollbar.
CanvasGadget was the solution to this.
No flickering anymore as I set backgrounds of container and canvas to same color.
Even with more complex background -> can get and set image with catchimage if needed:-)
It was important for me to got the bindgadgetevents working; using window callback or window event loop would have needed to keep track of current gadget to handle events for.
Thanks a lot, indeed!
[SOLVED];PB5.30; Win7; event handling; Canvas, Hide, Z-Index
o.k. now bindgadgetevent for the overlaying gadgets did not work anymore
Finally, RASHADS hint from another post helped:
and don't forget to use setActiveGadget on canvasgadget to reenable mousewheel...
Without the forum I would be lost with PB...

Finally, RASHADS hint from another post helped:
Code: Select all
SetWindowLongPtr_(GadgetID(PB), #GWL_STYLE, GetWindowLongPtr_(GadgetID(PB), #GWL_STYLE) | #WS_CLIPSIBLINGS)
SetWindowPos_(GadgetID(PB), #HWND_BOTTOM, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)
Without the forum I would be lost with PB...