[futurebasic] Re: [FB] MOUSE(_mouseWindow)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2011 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Mon, 21 Mar 2011 22:03:46 +1300
Alain Wrobel wrote:

>> Does the code need to determine the window without a mouse click?
> It's exactly my question.
> In FB^4 the following code returns the WINDOW ID (or 0 if the mouse is not over an FB window) without a mouse click !

> '---------------
> Window 1, "window 1"
> window 2, "window 2"
> 
> do
> locate 0,0:cls line :print "wndNum = ";mouse( _mouseWindow )
> HandleEvents
> until ( gFBQuit )
> '---------------


A handler for kEventMouseMoved allows you to discover the window under the mouse.

'-------
local mode
local fn MouseMovedHandler( nextHandler as EventHandlerCallRef, theEvent as EventRef, userData as ptr ) as OSStatus
'~'1
dim as WindowRef   w
dim as long        mouseOverWndNum, oldOut

fn CEParamGetWindowRef( theEvent, @w )
mouseOverWndNum = fn WPtr2WNum( w )

oldOut = window( _outputWnd )
window output 3
text , 20
print @(1, 1) mouseOverWndNum
window output oldOut
end fn = _eventNotHandledErr

window 1
window 2
window 3
fn CEAddEvent( _kEventClassMouse, _kEventMouseMoved )
fn CEInstallApplicationEventHandler( @fn MouseMovedHandler, 0, 0 )
HandleEvents
'-------

Robert P.