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

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

From: Dan Baeckström <dan.baeckstrom@...>
Date: Sun, 26 Jun 2011 21:09:35 +0200

Alain's code obviously works very well. However, parts of it read like  
modern poetry to me. I can grasp that
fn CEInstallControlEventHandler( button&(_bouton1), @fn  
MyControlHitHandler,_bouton1,0 )
gives instructions to execute fn MyControlHitHandler when the  
specified control event has occurred to the specified individual  
control. What fail to understand (revealing the depth of my ignorance  
here - again) is where fn MyControlHitHandler gets its arguments from.  
The parameters are obviously "known" to the program once the event has  
occurred, but how does it know how to put them in the right order in  
fn MyControlHitHandler's argument list?

Regards,

Dan



On 23 Jun 2011, at 13:59, Alain Wrobel wrote:

>
> 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
> ________________________________________________________________________
>
>
>
>
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
> To access the list archives, go to:  http://freegroups.net/groups/futurebasic/
>