Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Unable to capture mouse events in Win32::Console

by fireblood (Scribe)
on Apr 29, 2022 at 13:14 UTC ( #11143432=note: print w/replies, xml ) Need Help??


in reply to Re: Unable to capture mouse events in Win32::Console
in thread Unable to capture mouse events in Win32::Console

The one aspect of this that I still find puzzling is that in the @info array, all of the Y values are usually greater than the height of my console window. Do they represent Y values within the console buffer rather than within the console window? In my case the console buffer is much taller than the console window. I was not able to find an answer at https://docs.microsoft.com/en-us/windows/console/reading-input-buffer-events

  • Comment on Re^2: Unable to capture mouse events in Win32::Console

Replies are listed 'Best First'.
Re^3: Unable to capture mouse events in Win32::Console
by pryrt (Abbot) on Apr 29, 2022 at 13:57 UTC
    It took me a while to figure that one out as well. It's the character-based y coordinate relative to the first (top) line of text in the console, assuming your scroll bar is at the very top. So if your window is 25 lines tall but your history is 50 characters tall total, then if you scroll to the top , it will say the y is line 0, and if you scroll to the bottom, it will say the line is 49.

    When I originally had a \n in my ->Write() string, I was confused why the y coordinate would start increasing and "never" stop, even as I moved the cursor back up the screen. So I changed it to a \r instead, so the text wouldn't scroll the screen, and it suddenly made perfect sense, as I manually scrolled or intentionally moved down a line for printing (typing an ENTER, because the keyboard events still kept \n). (I also didn't realize until I did that -- though it should have been obvious, even from the x coordinate -- that the coordinates were in characters, not in pixels.)


    update: My original reply was assuming you were talking about the mouse coordinates from @console_events. Sorry I misread. But yes, the current x and current y, in the info array as well, are still relative to the top-left of the whole buffer, so the whole size and current location can be outside the window dimensions.

      Hi pryrt, excellent! That explains it all. So to determine the actual Y-coordinate within the console window all that will be required is to subtract the Y-coordinate in the buffer from the Y-coordinate of the top of the console window in the buffer.

      Thanks much!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11143432]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2022-12-03 09:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?