
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM
|
MOUSE
Make the mouse works like a button over invisible areas
I'm still trying to get my application to not need a keyboard to use but to use the mouse to do all the work during a presentation. Thanks for all the advice on double and triple clicking. As discussed there appears to be no straightfoward way to have different, non superset, funtions called from different clicks.
My next plan is to use the mouse to press buttons. This would be easy (put a toolbar full of buttons on the screen with appropriate handlers) if I didn't want the screen to look simple and uncluttered for a slick presentation. I thought of having invisible buttons 'superimposed' on the window and edit fields so I could click where I know a button to be but the audience doesn't see it.
I found that if that the buttons are initially invisible if I create the edit fields after I create the buttons. But once the button is pushed it draws over the edit fields and I can't get the edit fields back in front. Using _CDEFNoOutline didn't help. Does anybody have any suggestions on how to add 'invisible buttons' that stay invisible?
Sure... just don't use buttons! You can get the "x,y" location of a mouse click and base your responses on that, using the single-click event handler, or you can create "regions" on screen and test for whether the x-y position was within the region. (Same thing, only you don't have as much calculation in the event handler.)
For example, if you wanted a click anywhere in the "right half" of the screen to be "go to next page" and a click anywhere in the "left half" to be "go to prior page" _unless_ the mouse was at the top, in which case you want to quit... I'd do something like this;
DIM mouseX,mouseY,screenMidX
mouseX = MOUSE(_horz)
mouseY = MOUSE(_vert)
screenMidX = SYSTEM(_scrnWidth) / 2
LONG IF mouseX > screenMidX
INC(gPg%)
FN pageChange
XELSE
LONG IF mouseY < 20 'at top of screen
gProgramEnds% = _zTrue
XELSE
DEC(gPg%)
FN pageChange
END IF
END IF
Sure. You don't need any buttons, icons, picts, edit fields or anything. Just a couple of functions like this :
LOCAL FN HandleMouse
DIM rect;0,T,L,B,R:' default rect to use
DIM My,Mx:' for holding the mouse x/y
DIM Myy,Mxx:' second position for the mouse
Mact=MOUSE(0):' get any event since last mouse press
Mx=MOUSE(_horz):My=MOUSE(_vert):' get the mouse position
SELECT WINDOW(_activeWnd):' see which window we are clicking in
CASE _MYDISPLAYWINDOW
btnVal=FN HandleToolBar(@My):' see if they clicked in the toolbar
LONG IF btnVal:' did we find a rect
SELECT btnVal:' see what they wanted
CASE 1:' etc
CASE 2:' etc 2
END SELECT
END IF
END SELECT
END FN
'
LOCAL FN testToolBar(theMouse&):' at this point we test the toolbar
DIM rect;0,T,L,B,R:' default rect to use
DIM deMousePt;0,chkMY,chkMX:' my mouse points
wndPtr&=WINDOW(_wndPointer):' get a pointer to the window
rect;8=wndPtr&+_PortRect:' get TLBR of my window
totalBtns=(R-L)/32:' find out how many buttons will fit
B=31:R=32:' set the starting rect
deMousePt;4=theMouse&:' copy over the point they clicked at
found=_False:' show that nothing was found
theFunction=1:' the starting function number
DO
LONG IF FN PTINRECT(deMousePt,rect):' find the icon yet?
CALL INVERTRECT(rect):' use this for testing
WHILE FN BUTTON
WEND
DELAY 100
CALL GETMOUSE(deMousePt):' find where the mouse is now
LONG IF FN PTINRECT(deMousePt,rect):' still on the icon
found=theFunction:' make it a number from 1 to whatever
END IF
XELSE
INC(theFunction):' point to the next function
CALL OFFSETRECT(rect,32,0):' and step the rect to the right now
END IF
UNTIL theFunction>totalBtns OR found:' go til something happens
END FN=found
'
The first one gets shoehorned into where ever you go in your routine when the mouse is needed to be handled. The second simply checks to see where the user click in the active window.
Nothing is drawn in either, although I'd leave in the INVERTRECT to see how it works and to test it for yourself.
Hope this helps. BTW: if you want to have the buttons vertical, change the OFFSETRECT to something like CALL OFFSETRECT(rect,0,32) and then figure out how many buttons of 32 x 32 fit DOWN the screen. If you want bigger hot rects, just change the size, calcs and offsets.
|