Page 1 of 1

Trackpad left/right

Posted: Wed Mar 13, 2019 7:06 pm
by wombats
Hi,

We can detect up/down movements on a mouse wheel for the CanvasGadget and OpenGLGadget, but not left/right, etc. How can I test for these? My computer doesn't even report an event on #WM_MOUSEWHEEL when I move to the left or right. :/

Re: Trackpad left/right

Posted: Wed Mar 13, 2019 7:51 pm
by RASHAD
Mouse Wheel is just a status + or -
The rest is the programmer aim

Code: Select all

If OpenWindow(0, 0, 0, 800, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ContainerGadget(10,10,10,780,380)
    CanvasGadget(0, -1000, 0, 2000, 380)
  CloseGadgetList()
  LoadImage(0, #PB_Compiler_Home + "examples/Sources/Data/PureBasicLogo.bmp")   
  StartDrawing(CanvasOutput(0))
    DrawImage(ImageID(0),800,120)
  StopDrawing()
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
        
      Case #WM_MOUSEWHEEL
        Debug Sign(EventwParam())
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            Select EventType()
              Case #PB_EventType_MouseWheel
                Value = GetGadgetAttribute(0,#PB_Canvas_WheelDelta )
                x = GadgetX(0)+value*10
                If x > -100
                  x = -100
                ElseIf x < -1250
                  x = -1250
                EndIf
                ResizeGadget(0,x,#PB_Ignore, #PB_Ignore,#PB_Ignore)
            EndSelect
        EndSelect
    EndSelect         
  Until Quit = 1
EndIf

Re: Trackpad left/right

Posted: Wed Mar 13, 2019 8:39 pm
by wombats
Hi,

Thanks for the example, but I'm not sure it's what I'm looking for. Is it supposed to just go from side to side when you move up and down on the trackpad? The example doesn't do anything when I scroll left or right on my trackpad.

I'm looking to recreate the behaviour in editors that scroll in both directions - you can scroll the view with the trackpad in any direction.

Re: Trackpad left/right

Posted: Wed Mar 13, 2019 10:10 pm
by RASHAD
viewtopic.php?t=59343&p=533184

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_X, GetGadgetAttribute(0, #PB_ScrollArea_X) - wheel * 3)
            EndIf
           
        EndSelect
    EndSelect
  ForEver
EndIf

Re: Trackpad left/right

Posted: Thu Mar 14, 2019 5:59 am
by wombats
The ScrollAreaGadget doesn't respond to horizontal trackpad movements on my laptop.

I'm trying to create the functionality programs like Paint offer where you can scroll around the editing area with the trackpad. Is this just not possible in PureBasic on Windows?