MOUSEY - QB64 Wiki

MOUSEY

From QB64 Wiki

Revision as of 19:06, 29 September 2012 by Clippy (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

_MOUSEY Function returns the current vertical(row) mouse cursor position when read after _MOUSEINPUT.


Syntax:

row% = _MOUSEY


Usage:

  • SCREEN 0 returns the SINGLE vertical text row position. Graphic screens return the INTEGER pixel row.
  • 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.


Example: Highlighting a row of text in Screen 0.

minX = 20: maxX = 60: minY = 10: maxY = 24 selection = 0 'the screen Y coordinate of the previously highlighted item FOR i% = 1 TO 25: LOCATE i%, 40: PRINT i%;: NEXT DO: _LIMIT 100 IF _MOUSEINPUT THEN 'Un-highlight any selected row IF selection THEN selectRow selection, minX, maxX, 0 x = CINT(_MOUSEX) y = CINT(_MOUSEY) IF x >= minX AND x <= maxX AND y >= minY AND y <= maxY THEN selection = y ELSE selection = 0 END IF 'Highlight any selected row IF selection THEN SelectRow selection, minX, maxX, 2 IF _MOUSEBUTTON(1) THEN LOCATE 1, 2: PRINT x, y, selection END IF LOOP UNTIL INKEY$ <> "" SUB SelectRow (y, x1, x2, col) DEF SEG = &HB800 addr& = (x1 - 1 + (y - 1) * _WIDTH) * 2 + 1 FOR x = x1 TO x2 oldCol = PEEK(addr&) AND &B10001111 ' Mask foreground color and blink bit POKE addr&, oldCol OR ((col AND &B111) * &B10000) ' Apply background color addr& = addr& + 2 NEXT END SUB


See also:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page