Trackpad-Scrolling inside a ScrollArea with Canvas dont work

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Trackpad-Scrolling inside a ScrollArea with Canvas dont work

Post by Lebostein »

move cursor outside the canvas and scroll - work
move cursor inside the canvas and try to scroll - don't work

Scrolling inside a "ScrollArea" should work in every cases. Or there some events to handle this?

Code: Select all

 If OpenWindow(0, 0, 0, 700, 400, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ScrollAreaGadget(0, 10, 10, 680, 380, 1000, 1000, 30)
      ButtonGadget  (1, 10, 10, 230, 30,"Button 1")
      ButtonGadget  (2, 50, 50, 230, 30,"Button 2")
      ButtonGadget  (3, 90, 90, 230, 30,"Button 3")
      CanvasGadget  (5, 200, 200, 500, 500)
      CloseGadgetList()
    StartDrawing(CanvasOutput(5))
    Box(0,0,500,500,$FF0000)
    StopDrawing()
    Repeat
      Select WaitWindowEvent()
        Case  #PB_Event_CloseWindow
          End
        Case  #PB_Event_Gadget
          Select EventGadget()
            Case 1
              MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
            Case 2
              MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
            Case 3
              MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)
          EndSelect
      EndSelect
    ForEver
  EndIf
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Trackpad-Scrolling inside a ScrollArea with Canvas dont

Post by mk-soft »

the CanvasGadget has except for Windows automatically focus. See Canvas help.

Solution:

Code: Select all

If OpenWindow(0, 0, 0, 700, 400, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ScrollAreaGadget(0, 10, 10, 680, 380, 1000, 1000, 30)
      ButtonGadget  (1, 10, 10, 230, 30,"Button 1")
      ButtonGadget  (2, 50, 50, 230, 30,"Button 2")
      ButtonGadget  (3, 90, 90, 230, 30,"Button 3")
      CanvasGadget  (5, 200, 200, 500, 500)
      CloseGadgetList()
    StartDrawing(CanvasOutput(5))
    Box(0,0,500,500,$FF0000)
    StopDrawing()
    Repeat
      Select WaitWindowEvent()
        Case  #PB_Event_CloseWindow
          End
        Case  #PB_Event_Gadget
          Select EventGadget()
            Case 1
              MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
            Case 2
              MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
            Case 3
              MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)
            Case 5
              If EventType() = #PB_EventType_MouseWheel
                wheel = GetGadgetAttribute(5, #PB_Canvas_WheelDelta)
                SetGadgetAttribute(0, #PB_ScrollArea_Y, GetGadgetAttribute(0, #PB_ScrollArea_Y) - wheel * 3)
              EndIf
              
          EndSelect
      EndSelect
    ForEver
  EndIf
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
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Trackpad-Scrolling inside a ScrollArea with Canvas dont

Post by Danilo »

What about left-right scrolling / left-right wipe? There is no event to support that, and
#PB_Canvas_WheelDelta gives only values for up-down scrolling / up-down wiping gesture.

Within the ScrollArea, left-right scrolling/wiping works fine.

EDIT:
#PB_EventType_MouseWheel event fires also for left-right scrolling/wiping, but
#PB_Canvas_WheelDelta is always 0.
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Trackpad-Scrolling inside a ScrollArea with Canvas dont

Post by Danilo »

Danilo wrote:What about left-right scrolling / left-right wipe?
- CanvasGadget GetWheelDeltaX() + GetWheelDeltaY()
Fred
Administrator
Administrator
Posts: 16688
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Trackpad-Scrolling inside a ScrollArea with Canvas dont

Post by Fred »

It's the intended behaviour (all mouse event in the canvas have the priority. We could still add a flag like '#PB_Canavas_DisableWheel' to allow this easily.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Trackpad-Scrolling inside a ScrollArea with Canvas dont

Post by collectordave »

Hi all

Just a little confused.

Ran the example above and found the scrolling does not accur until the scrollarea gadget is clicked.

Looked like the canvas gadget did the scrolling so experimented by taking out the canvas gadget. Same again.

here is the code

Code: Select all

If OpenWindow(0, 0, 0, 700, 400, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ScrollAreaGadget(0, 10, 10, 680, 380, 1000, 1000, 30)
      ButtonGadget  (1, 10, 10, 230, 30,"Button 1")
      ButtonGadget  (2, 50, 50, 230, 30,"Button 2")
      ButtonGadget  (3, 90, 90, 230, 30,"Button 3")
      CloseGadgetList()
    
    Repeat
      Select WaitWindowEvent()
        Case  #PB_Event_CloseWindow
          End
        Case  #PB_Event_Gadget
          Select EventGadget()

            Case 1 
              MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
            Case 2
              MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
            Case 3
              MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)

          EndSelect
      EndSelect
    ForEver
  EndIf
How can I get the scroll area gadget to scroll on mousewheel without clicling so just mouse over?

cross platform please.

regards

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Trackpad-Scrolling inside a ScrollArea with Canvas dont

Post by collectordave »

Reading more think it can be done.

Added

Code: Select all

TextGadget(4,10,140,100,40,"")
HideGadget(4,#True)
Just after last button gadget then

SetActiveGadget(4)

After closegadgetlist()

Works First time even with a canvasgadget added again.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Post Reply