[futurebasic] Re: [FB] Drawing to a window with the _kWindowMetalAttribute ??

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2006 : Group Archive : Group : All Groups

From: Brian Stevens <brilor@...>
Date: Tue, 18 Apr 2006 15:08:42 -0700
On Apr 18, 2006, at 2:36 PM, Bill Sanford wrote:

> One thing I can't figure out is how to get mouse presses in a user  
> area of
> the metal window.
I'm assuming you mean some kind of control like an edit field (static  
or live), user pane or something like that?   See next response too.


>
> Is here a way to capture mouse events in a defined rectangle in the  
> window
> and pass them to FB's ON MOUSE handler?
Well, there are many ways to do this including ON EVENT trapping and  
a CE handler is also possible. ON MOUSE fn xxxxx only handles certain  
kinds of mouse clicks, so it might not work (see FB reference manual  
for limitations). To trap anything use an ON EVENT vector and trap  
the mouse button down event (_mButDwnEvt). The code snippet below is  
not runnable but provides some idea of how to trap a user click. In  
this case we retrieve the rectangle of a specific control/button  
(could be user pane or whatever) then check to see if the mouse point  
is inside the rectangle (PtInRect). If it is we do something. ON  
EVENT trapping captures events before the standard FB runtime sees  
them, so there is some extra responsibility here. Please check the  
reference manual to make sure you are comfortable with these points.

local FN doEvent
dim ev as ^EventRecord
dim as rect        btnRect
dim as point       mousePt
dim as WindowRef @ wNum

ev = event'PEEK at event record
wNum = mouse(_mouseWindow)
select ev.what
case _mButDwnEvt
case wNum == _myWindow  ' if it is my window do something......
mousePt = ev.where
GlobalToLocal(mousePt)
fn FBGetControlRect(button&(_SomeControlorButton), btnRect)'if click  
on date/time on top of calendar
long if fn PtInRect(mousePt, btnRect)
do something here
end if

end select
end select
>
> I also need to trap and handle window resizing by the user dragging  
> the
> resize area in the lower right part of the window.
window resizing is a broad topic. Do you want to do live resizing?   
One method I use is a generic resize handler which I pass a pointer   
to my resize fn. If you are willing to go further and use the new  
layout options to bind controls to windows, the resize is handled  
automatically and a resize fn is unnecessary. I believe there are  
examples on the CD, but if not just shout and I'll get some to you.

HTH...

Brian S.