It is currently Mon Sep 23, 2019 9:24 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Trackpad left/right
PostPosted: Wed Mar 13, 2019 7:06 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 451
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. :/


Top
 Profile  
Reply with quote  
 Post subject: Re: Trackpad left/right
PostPosted: Wed Mar 13, 2019 7:51 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3402
Mouse Wheel is just a status + or -
The rest is the programmer aim
Code:
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

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Trackpad left/right
PostPosted: Wed Mar 13, 2019 8:39 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 451
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Trackpad left/right
PostPosted: Wed Mar 13, 2019 10:10 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3402
https://www.purebasic.fr/english/viewtopic.php?t=59343&p=533184

Code:
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

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Trackpad left/right
PostPosted: Thu Mar 14, 2019 5:59 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 451
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?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye