[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"


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

window 1

dim as rect rct

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

until gFBQuit


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