1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00
QB64-PE/internal/help/_MOUSEY.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

65 lines
2.6 KiB
Plaintext

{{DISPLAYTITLE:_MOUSEY}}
The [[_MOUSEY]] function returns the current vertical (row) mouse cursor position when read after [[_MOUSEINPUT]].
{{PageSyntax}}
: {{Parameter|pixelRow%}} = [[_MOUSEY]]
{{PageDescription}}
* [[SCREEN]] 0 returns the [[INTEGER]] vertical text row position (from build 20170817/62 onward); older versions return a [[SINGLE]] vertical text row position. Use [[INTEGER]] variables to avoid floating decimal returns.
* Graphic screen modes 1, 2 and 7 to 13 and [[_NEWIMAGE]] 32 bit return the [[INTEGER]] pixel columns.
* To calculate text rows in graphic modes divide the return by 16 or the [[_FONTHEIGHT]] of [[_FONT]] characters.
* [[_MOUSEINPUT]] must be used to detect any changes in the mouse position and is '''required''' for any coordinate returns.
==QBasic/QuickBASIC==
* In [[SCREEN]] 0, QBasic's [[ABSOLUTE]] returned graphic coordinates. QB64 mouse functions return the text coordinates.
{{PageExamples}}
''Example:'' Highlighting a row of text in Screen 0.
{{CodeStart}} '' ''
minX = 20: maxX = 60: minY = 10: maxY = 24
selection = 0 'the screen Y coordinate of the previously highlighted item
{{Cl|FOR}} i% = 1 {{Cl|TO}} 25: {{Cl|LOCATE}} i%, 40: {{Cl|PRINT}} i%;: {{Cl|NEXT}}
{{Cl|DO}}: {{Cl|_LIMIT}} 100
{{Cl|IF}} {{Cl|_MOUSEINPUT}} {{Cl|THEN}}
'Un-highlight any selected row
{{Cl|IF}} selection {{Cl|THEN}} selectRow selection, minX, maxX, 0
x = {{Cl|_MOUSEX}}
y = {{Cl|_MOUSEY}}
{{Cl|IF}} x >= minX {{Cl|AND (boolean)|AND}} x <= maxX {{Cl|AND (boolean)|AND}} y >= minY {{Cl|AND (boolean)|AND}} y <= maxY {{Cl|THEN}}
selection = y
{{Cl|ELSE}}
selection = 0
{{Cl|END IF}}
'Highlight any selected row
{{Cl|IF}} selection {{Cl|THEN}} SelectRow selection, minX, maxX, 2
{{Cl|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} {{Cl|LOCATE}} 1, 2: {{Cl|PRINT}} x, y, selection
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> ""
{{Cl|SUB}} SelectRow (y, x1, x2, col)
{{Cl|DEF SEG}} = {{Cl|&H}}B800
addr& = (x1 - 1 + (y - 1) * {{Cl|_WIDTH (function)|_WIDTH}}) * 2 + 1
{{Cl|FOR}} x = x1 {{Cl|TO}} x2
oldCol = {{Cl|PEEK}}(addr&) {{Cl|AND (boolean)|AND}} {{Cl|&B}}10001111 ' Mask foreground color and blink bit
{{Cl|POKE}} addr&, oldCol {{Cl|OR}} ((col {{Cl|AND (boolean)|AND}} {{Cl|&B}}111) * {{Cl|&B}}10000) ' Apply background color
addr& = addr& + 2
{{Cl|NEXT}}
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{PageSeeAlso}}
* [[_MOUSEX]], [[_MOUSEBUTTON]], [[_MOUSEWHEEL]]
* [[_MOUSEINPUT]], [[_MOUSEMOVE]]
* [[_MOUSESHOW]], [[_MOUSEHIDE]]
* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] {{text|(relative pointer moves)}}
* [[Controller Devices]]
{{PageNavigation}}
<