Mail Archives: djgpp/1997/04/11/02:44:38
On Fri, 11 Apr 1997, Patrick G. Kutch wrote:
> for (c=0; d[c].proc; c++)
> if ((mouse_x >= d[c].x) && (mouse_y >= d[c].y) &&
> (mouse_x < d[c].x + d[c].w) && (mouse_y < d[c].y + d[c].h) &&
> (!(d[c].flags & (D_HIDDEN | D_DISABLED))))
> {
> mouse_object = c;
> break;
> }
>
> return mouse_object;
> However, this causes all kind of problems. After doing this, the
> routine doesn't seem to work properly. The focus will be lost while
> definitley moving over a button.
I'm guessing that Allegro uses the last-in-first-to-get-focus stack. When
you short-circuit the for-loop, some of the later objects lose their
ability to get the focus. If you want to optimize this loop, set a
pointer to the current last object in the list (maintain it too! :) and
step backwards like so:
for (c = last_element;; c--)
if (blah)
{
mouse_object = c;
break;
}
return mouse_object;
This will act in the same way as the current Allegro proc. I'm not 100%
sure that Allegro does it this way, but give it a try. :)
/\/\att /\/\astracci mmastrac AT acs DOT ucalgary DOT ca
GCS/GE d- s+:+ a--- C++++ UA P+ L E-- W+ N++ o K+ w+ O M- V
PS++ PE++ Y+ PGP t+++ 5+++ X++ R++ tv+ b+++ DI++++ I
G++ e h r* z?
- Raw text -