[futurebasic] Re: [FB] A few questions about USR HANDLE2BTN

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2004 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Wed, 19 May 2004 22:53:31 +1200
Alain Wrobel wrote:

> 		Bonjour,
>
> 	Why in the following example in the case of a mouse clic
>
> 1) over a button  USR HANDLE2BTN returns the number of the button 
> (normal behaviour)
> 2) over nothing or over a static edit field USR HANDLE2BTN returns the 
> number of the first non static edit field (7 in the example)

This anomaly is due to FindControl. Apple says
"The  FindControl function is not recommended when the Appearance 
Manager is available. When the Appearance Manager is available, you 
should call FindControlUnderMouse to determine the location of a 
mouse-down event in a control."

Instead of
evenement=fn findcontrol(ou,window(_wndPointer),hndleBouton)
use
hndleBouton = fn FindControlUnderMouse( ou, window( _wndPointer ), 
@evenement )

By the way, where you have used the variable name evenement I would 
write partCode (or a suitable translation thereof). That makes it 
easier to see that the value 10 shown on clicking a push button is 
_kControlButtonPart.

> 3) over a non static edit field USR HANDLE2BTN returns the number of 
> the edit field (i.e. risk of confusion with the first case)
> (are non static edit fields something like pseudo-buttons in the 
> Appearance runtime ?)

In the Appearance Runtime all edit fields, static and editable, are 
controls ("buttons").

> subsidiary question : why the _statFramed edit fields are they not 
> framed ?

The frames are drawn at HandleEvents time.  Add 5 or 6 HandleEvents 
statements before you enter the loop.

Robert P.

> (FB^3 v7, CPU PPC, Basic Appearance)
>
> window 1
> dim rct as rect
> dim hndleBouton as handle
> dim ou as point
> dim evenement
> dim clicOu
>
>
> setrect(rct,10,10,180,26)
> button 10,_activeBtn,"bouton 10",@rct,_push
> offsetrect(rct,0,40)
> edit field 7,"champ 7",@rct,_framed
> offsetrect(rct,0,40)
> edit field 20,"champ 20",@rct,_framed
> offsetrect(rct,0,40)
> edit field 10,"champ 10",@rct,_framed
> offsetrect(rct,0,40)
> button 20,_activeBtn,"bouton 20",@rct,_push
> offsetrect(rct,0,40)
> edit field 50,"champ 50",@rct,_framed
> offsetrect(rct,0,40)
> button 50,_activeBtn,"bouton 50",@rct,_push
> offsetrect(rct,190,0)
> edit field 30,"",@rct,_statFramed
> offsetrect(rct,0,40)
> edit field 35,"",@rct,_statFramed
> offsetrect(rct,0,40)
> edit field 40,"",@rct,_statFramed
> offsetrect(rct,0,40)
> edit field 60,"press any key to stop",@rct,_statFramed
>
> do
> long if fn button
> getmouse(ou)
> evenement=fn findcontrol(ou,window(_wndPointer),hndleBouton)
> clicOu=usr handle2btn(hndleBouton)
> edit$(30)="bouton ou champ"+str$(clicOu)
> edit$(35)="evenement"+str$(evenement)
> edit$(40)="hndleBouton"+str$(hndleBouton)
> end if
> until len(inkey$)