Keyboard shortcuts for mouse wheel

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

Hello Fred,

Could you add two new types of keyboard shortcuts regarding if one scrolls the mouse wheel up or down?
#PB_Shortcut_MouseWheel_Up
#PB_Shortcut_MouseWheel_Down
?

Or something like that?

It would be very useful if one uses virtual ListIconGadgets, since I have been asking for help regarding them and no one seems to give a solution to the problem.

Thanks!
User avatar
Bisonte
Addict
Addict
Posts: 1163
Joined: Tue Oct 09, 2007 2:15 am

Re: Keyboard shortcuts for mouse wheel

Post by Bisonte »

Keyboard Shortcuts ?

I think you mean EventTypes....

But normally, you can scroll in a Listview with the Cursor up&down keys....

or if you made a Listview by yourself.. you have to create such functionality ;)
PureBasic 5.73 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

Bisonte wrote:Keyboard Shortcuts ?

or if you made a Listview by yourself.. you have to create such functionality ;)
How?
User avatar
Bisonte
Addict
Addict
Posts: 1163
Joined: Tue Oct 09, 2007 2:15 am

Re: Keyboard shortcuts for mouse wheel

Post by Bisonte »

This depends on how you created the ListView.
If you show the complete code of your ListView, there is probably
someone who can implement this function. Maybe even me ;)
PureBasic 5.73 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

Bisonte wrote:This depends on how you created the ListView.
If you show the complete code of your ListView, there is probably
someone who can implement this function. Maybe even me ;)
It is a ListIconGadget, not a ListView.
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

Anyway, the project is open-source.

You can download the source from its official page:
http://proofingtoolgui.org

However, I am currently working on build 120 which will be release after Fred updates PB 5.61 since there are issues with Ubuntu 17.10.

On build 120 I have been cleaning the code to make everything look better.
User avatar
Bisonte
Addict
Addict
Posts: 1163
Joined: Tue Oct 09, 2007 2:15 am

Re: Keyboard shortcuts for mouse wheel

Post by Bisonte »

If it is a normal ListIconGadget, you can scroll the list with the cursor keys (on windows) if it has the focus....
PureBasic 5.73 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

Bisonte wrote:If it is a normal ListIconGadget, you can scroll the list with the cursor keys (on windows) if it has the focus....
It is not a normal ListIconGadget as I download the lines into an array, and only show 13 at a time (customisable).

I had to code by hand the curs up/down.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Keyboard shortcuts for mouse wheel

Post by Dude »

marcoagpinto wrote:Could you add two new types of keyboard shortcuts regarding if one scrolls the mouse wheel up or down?
Marco, is this what you want? (Windows only).

Code: Select all

If OpenWindow(0,300,300,400,200,"MouseWheel",#PB_Window_SystemMenu)
  TextGadget(0,20,20,200,20,"Scroll the mouse wheel...")
  Repeat
    ev=WaitWindowEvent()
    If ev=#WM_MOUSEWHEEL
      If EventwParam()>0
        SetGadgetText(0,"UP")
      ElseIf EventwParam()<0
        SetGadgetText(0,"DOWN")
      EndIf
    EndIf
  Until ev=#PB_Event_CloseWindow
EndIf
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

Dude wrote:
marcoagpinto wrote:Could you add two new types of keyboard shortcuts regarding if one scrolls the mouse wheel up or down?
Marco, is this what you want? (Windows only).

Code: Select all

If OpenWindow(0,300,300,400,200,"MouseWheel",#PB_Window_SystemMenu)
  TextGadget(0,20,20,200,20,"Scroll the mouse wheel...")
  Repeat
    ev=WaitWindowEvent()
    If ev=#WM_MOUSEWHEEL
      If EventwParam()>0
        SetGadgetText(0,"UP")
      ElseIf EventwParam()<0
        SetGadgetText(0,"DOWN")
      EndIf
    EndIf
  Until ev=#PB_Event_CloseWindow
EndIf

The idea looks good, but if one increases the bars, the ListIconGadget gets an horizontal scroll bar and the mouse wheel will scroll it (while showing 13 at a time).

Image

Is there a way of using your code also on Linux and Mac and disabling the horizontal scroll bar from being affected by the mouse wheel?

Thank you!
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

@Dude

Maybe, as a workaround, I could bind the mouse wheel scroll to the vertical scroll bar, so that when over it, it would scroll.

But, I still need to know how to get the wheel event to Linux and Mac.

Could you help?

Thank you, my friend!
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Keyboard shortcuts for mouse wheel

Post by Dude »

I don't use Linux or Mac, so I can't help further, sorry. :(
User avatar
TI-994A
Addict
Addict
Posts: 2490
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore

Re: Keyboard shortcuts for mouse wheel

Post by TI-994A »

Take a look at this:

> Virtual Scroll
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!
User avatar
marcoagpinto
Enthusiast
Enthusiast
Posts: 712
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Keyboard shortcuts for mouse wheel

Post by marcoagpinto »

Now seriously,

Look at the help for the ScroolBarGadget():

Code: Select all

Example: ScrollBar events

  Procedure BindHScrollDatas()
    SetWindowTitle(0, "ScrollBarGadget (" + GetGadgetState(0) + ")" )
  EndProcedure

  Procedure BindVScrollDatas()
    SetWindowTitle(0, "ScrollBarGadget (" + GetGadgetState(1) + ")" )
  EndProcedure


  If OpenWindow(0, 0, 0, 400, 400, "ScrollBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
    TextGadget       (2,  10, 25, 350,  30, "ScrollBar Standard  (start = 50, page = 30/100)")
    ScrollBarGadget  (0,  10, 50, 350,  20, 0, 100, 30)
    SetGadgetState   (0,  50)   ; set 1st scrollbar (ID = 0) to 50 of 100
    TextGadget       (3,  10, 120, 350,  30, "ScrollBar vertical  (start = 100, page = 50/300)")
    ScrollBarGadget  (1, 175, 160,  25, 120 ,0, 300, 50, #PB_ScrollBar_Vertical)
    SetGadgetState   (1, 100)   ; set 2nd scrollbar (ID = 1) to 100 of 300
  
    BindGadgetEvent(0, @ BindHScrollDatas())
    BindGadgetEvent(1, @ BindVScrollDatas())
  
    Repeat 
      Select WaitWindowEvent() 
        Case  #PB_Event_CloseWindow 
          End 
        Case  #PB_Event_Gadget 
          Select EventGadget()
            Case 0
              MessageRequester("Info","The ScrollBar 0 has been used ! (" + GetGadgetState(0) +
                                      ")" ,#PB_MessageRequester_Ok)
            Case 1
              MessageRequester("Info","The ScrollBar 1 has been used ! (" + GetGadgetState(1) +
                                      ")" ,#PB_MessageRequester_Ok) 
            
          EndSelect 
      EndSelect
    ForEver 
  EndIf
What is the point of this, if it doesn't allow scroll with the mouse wheel?

Fred, could you take it as a feature request?

Thank you!
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Keyboard shortcuts for mouse wheel

Post by Dude »

The code I posted above is no longer useful for 64bit PureBasic because it doesn't return negative or positive values for the wheel direction. Is there some sort of ">>" math trick to make it work again?
Post Reply