Hi, I m working on a program that requires a canvasgadget inside a scroll area gadget and I discovered that if you place the mouse over the canvas gadget the scroll area ignores the mousehweel so you need to make a work around in order to scroll the scroll area with the mouse wheel by using a code like this
Code:
Procedure moveChipset()
SetGadgetAttribute(#chipsetArea,#PB_ScrollArea_Y,GetGadgetAttribute(#chipsetArea,#PB_ScrollArea_Y)-GetGadgetAttribute(#chipsetCanvas, #PB_Canvas_WheelDelta))
EndProcedure
BindGadgetEvent(#chipsetCanvas,@moveChipset(),#PB_EventType_MouseWheel)
You can see the whole code on the initial post
viewtopic.php?f=13&t=76275This workaround helps. to fix the issue with the vertical scrolling. The problem comes when you have a scroll area that also needs to be scrolled horizontally as it looks the mousewheel delta detects 0 when you tap the shift key at the same time, so there is no way to tell the program that im trying to scroll horizontally as the mousewheeldelta returns 0
Is there any workaround to this issue? or am I missing any event that returns the horizontal mousewheel in a mac?
Many thanks
Edit: I found a workaround based on the code of @wilbert here
http://forums.purebasic.com/english/vie ... 332b85ccb3What i did is the following
Code:
#NSScrollWheel = 22
Global sharedApplication = CocoaMessage(0, 0, "NSApplication sharedApplication")
Define currentEvent, type, modifierFlags, keyCode
Define deltaX.CGFloat, deltaY.CGFloat
Procedure moveMap()
Shared currentEvent, type, deltaX, deltaY, sharedApplication
currentEvent = CocoaMessage(0, sharedApplication, "currentEvent")
type = CocoaMessage(0, currentEvent, "type")
If currentEvent
type = CocoaMessage(0, currentEvent, "type")
If type = #NSScrollWheel
CocoaMessage(@deltaX, currentEvent, "deltaX")
CocoaMessage(@deltaY, currentEvent, "deltaY")
Debug "Mouse wheel delta (" + StrF(deltaX, 1) + "," + StrF(deltaY, 1) + ")"
EndIf
EndIf
SetGadgetAttribute(#mapArea,#PB_ScrollArea_X,GetGadgetAttribute(#mapArea,#PB_ScrollArea_X)-deltaX)
SetGadgetAttribute(#mapArea,#PB_ScrollArea_Y,GetGadgetAttribute(#mapArea,#PB_ScrollArea_Y)-deltaY)
EndProcedure
BindGadgetEvent(#mapCanvas,@moveMap(),#PB_EventType_MouseWheel)
But there are a couple of things i dont like about this solution
- First; it doesnt feel that smooth as my solution for the vertical scrolling, the scroll is done slower but im afraid this would be different per computer so i wont change it. (maybe im wrong) (if I multiply it x4 it works very similar to the default scrollareagadget but i donno what are the implications of doing this)
- Second: This cocoa codes feels like dark magic to me, im not sure exactly what im doing..
- Third: It wont be a multiplatform solution as cocoa is mac only (but maybe in windows this issue doesnt happen I didnt research enought and my workstation is a mac)
Any thoughts?