Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Suggestions ➜ send zDelta to miniwindow scrollwheel handler callback

send zDelta to miniwindow scrollwheel handler callback

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Fiendish   USA  (2,541 posts)  Bio   Global Moderator
Date Sun 05 May 2019 12:02 AM (UTC)

Amended on Sun 05 May 2019 12:05 AM (UTC) by Fiendish

Message
Right now wheel callbacks get only a boolean flag field indicating whether the wheel was spun up or down. I propose sending the full zDelta-derived number of lines value (as used for scrolling the main output) in addition. Native interface elements scroll differently for fast and slow spins, but miniwindows can't.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 05 May 2019 10:01 PM (UTC)

Amended on Sun 05 May 2019 10:02 PM (UTC) by Nick Gammon

Message
OK, I added the delta to the high-order 16 bits of the flags (for minimum compatibility disruption) however in my testing the delta amount was always 120.

The delta is unsigned, so you still have to test the flag. Example code:



win = "test_" .. GetPluginID ()  -- get a unique name, ensure not empty if outside plugin
WindowCreate (win, 0, 0, 200, 200, miniwin.pos_center_all, 0, ColourNameToRGB("white"))  -- create window
WindowShow (win,  true)  -- show it 

WindowAddHotspot(win, "hs1",  
                 10, 10, 100, 100,   -- rectangle
                 "",   -- mouseover
                 "",   -- cancelmouseover
                 "",   -- mousedown
                 "",   -- cancelmousedown
                 "",   -- mouseup
                 "Tooltip message",  -- tooltip text
                 miniwin.cursor_hand, 0)  -- hand cursor


function mousewheelhandler (flags, hotspotid)
  local delta = bit.shr (flags, 16)
  if bit.band (flags, miniwin.wheel_scroll_back) ~= 0 then
     print (delta, "backwards")
  else
     print (delta, "forwards")
  end -- if
end -- mousewheelhandler 

WindowRectOp (win, miniwin.rect_frame, 10, 10, 100, 100, ColourNameToRGB("blue")) 

WindowScrollwheelHandler(win, "hs1", "mousewheelhandler")



https://github.com/nickgammon/mushclient/commit/d2f7129

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,541 posts)  Bio   Global Moderator
Date Reply #2 on Sun 05 May 2019 10:17 PM (UTC)

Amended on Sun 05 May 2019 10:23 PM (UTC) by Fiendish

Message
Quote:
in my testing the delta amount was always 120


So how does the main body scroll with different velocities?

I just tested, and I'm getting something like:

Quote:

6
42
78
1170
1674
1188
3138
2604
2220
2562
2100
1284
1044
846
666
510
144
366
282
216
288
96
30
90
54
36
24
6
12
6
6


So it appears to work.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 05 May 2019 10:25 PM (UTC)
Message

Are you sure it does? If you scroll faster you get more “pulses”. Thus the window scrolls faster. Like, a bike speedometer measures the number of times the wheel turns, and the more pulses a second the faster it must be turning. However the interaction between the magnet and the sensor is binary, it doesn’t recall the time taken for the wheel to send one pulse. You recall the time by measuring the time between pulses.

Having said that, though, I am using Windows XP running under VirtualBox in Ubuntu. Maybe you will get different results with other versions of Windows, or if it is run natively.

It seems odd for Windows to return a number (delta) if it is always the same.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 05 May 2019 10:26 PM (UTC)
Message
Looks like my second theory is correct. You are getting better results than I did. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,541 posts)  Bio   Global Moderator
Date Reply #5 on Sun 05 May 2019 10:26 PM (UTC)

Amended on Sun 05 May 2019 10:27 PM (UTC) by Fiendish

Message
In macOS+Wine it appears to work, though I'm technically using a touchpad and not using a mouse. That may have something to do with it.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Fiendish   USA  (2,541 posts)  Bio   Global Moderator
Date Reply #6 on Sun 05 May 2019 10:43 PM (UTC)
Message
Somewhat humorously, using this wheel handler results in much more touchpad-friendly output scrolling than the default, I guess because it doesn't lock to whole line increments which are more difficult to hit without wheel clicks.


function ScrollMain(flags, hotspot_id)
   local delta = bit.shr(flags, 16)
   if bit.band (flags, miniwin.wheel_scroll_back) ~= 0 then
      direction = 1   -- wheel scrolled down
   else
      direction = -1  -- wheel scrolled up
   end
   SetScroll(GetInfo(296) + delta*direction, GetInfo(120))
end

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


22,871 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.