[futurebasic] Re: [FB] Detecting clicks in edit fields

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

From: Alain Wrobel <alain.wrobel@...>
Date: Thu, 23 Jun 2011 13:59:22 +0200
Le 23 juin 2011 à 12:24, Dan Baeckström a écrit :

> Is there any way to detect if a static edit field (ie an appearance button created with _kControlStaticTextProc) has been clicked, apart from mucking about with mouse click coordinates and comparing them to the edit field rects? I found a thread here from 1998 but unsurprisingly, the "convenient" method suggested there relied on a dialog function that is no longer supported. Alternatively (but less preferably), to create a push button without any visible features except the text string?
> 
> Regards,
> 
> Dan
> 


Maybe something like :

'---------------------

include "Util_CE.incl"

_bouton1=1
_bouton2=2
_message=3


local fn MyControlHitHandler( nextHandler as EventHandlerCallRef, theEvent as EventRef, btnNum as long )//Bernie
'~'1
dim as OSStatus      result : result = _eventNotHandledErr
'~'1
select fn GetEventClass( theEvent )
case _kEventClassControl
select fn GetEventKind( theEvent )
case _kEventControlHitTest
long if fn button
fn SETBUTTONTEXTSTRING(_message,FN ButtonTextString$( btnNum ))
flushwindowbuffer
result = _noErr 
do
until fn button=0
fn SETBUTTONTEXTSTRING(_message,"")
end if
end select
end select
end fn = result


window 1

dim as rect rct

setrect(rct,10,10,200,30)
appearance BUTTON _bouton1,_activeBtn,,,,, @rct, _kControlStaticTextProc
fn CEAddEvent(_kEventClassControl,_kEventControlHitTest)
fn CEInstallControlEventHandler( button&(_bouton1), @fn MyControlHitHandler,_bouton1,0 )
fn SETBUTTONTEXTSTRING(_bouton1,"texte statique 1")
offsetrect(rct,0,40)
appearance BUTTON _bouton2,_activeBtn,,,,, @rct, _kControlStaticTextProc
fn CEAddEvent(_kEventClassControl,_kEventControlHitTest)
fn CEInstallControlEventHandler( button&(_bouton2), @fn MyControlHitHandler,_bouton2,0 )
fn SETBUTTONTEXTSTRING(_bouton2,"texte statique 2")
offsetrect(rct,0,40)
appearance BUTTON _message,_activeBtn,,,,, @rct, _kControlStaticTextProc

do
handleevents
until gFBQuit

'---------------------



-- 
________________________________________________________________________
A. Wrobel * ESO-UMR 6590, Université du Maine/CNRS *Tel:02-43-83-35-44
________________________________________________________________________