harryk@bucsb.UUCP (_harryk) (12/11/89)
Have I found an AES's bug or i don't know what i'm doing?
Here is the problem:
I'm writing an ST application which is supposed to use KEYBORD-
EQUIVALENTS for almost every entry of the menus. So, (naturaly?)
i'm using the function evnt_multi() in order to handle MESSAGE
and KEYBOARD events. The thing works ok except one annoying pro-
blem:
If i press a key-equivalent, while any of the pull-down
menus is open, i'm getting the action that corresponds to
that keyboard-equivalent( i.e using the mouse i open the 'File'
menu and i place the mouse pointer on the entry 'Open', which
is becoming "selected"....now, instead of clicking on 'Open',
I press Ctrl-A (which is the equivalent for 'About xxxx' under
the menu title 'Desk'). Well, what happens is that the dilogue
box for the 'About' selection appears on the screen; and after
I exit the dialogue box, i'm getting the file selector). The
correct response should be NEITHER dialogue-box NOR file selector!
The code i'm using is the following:
int dummy, keypressed, msg_buffer[8], event;
OBJECT *menutree;
.
.
.
for(;;){
menu_bar(menutree, 1); /* enable the menu bar */
event = evnt_multi( MN_SELECTED | MU_KEYBD,
0,0,0, /* clicks, button, state */
0, 0,0,0,0, /* inrec, x1, y1, w1, h1 */
0, 0,0,0,0, /* outrec,x2, y2, w2, h2 */
msg_buffer, /* message buffer */
dummy, dummy, /* lowtime, hightime */
&dummy, &dummy, /* mouse coordinates */
&dummy, &dummy, /* bptr, kptr */
&keypressed, /* i want this one */
&dummy /* times */
);
menu_bar(menutree, 0); /* disable the menu bar */
if ( event & MU_KEYBD )
switch (keypressed){
........
/* case quit: rsrc_free(); appl_exit(); exit(0); */
}
else if (event & MN_SELECTED){ /* or just ... else */
switch (msg_buffer[4]){
........
/* case quit: rsrc_free(); appl_exit(); exit(0); */ */
}
} /* for */
The C compiler i'm using is MWC v3.0.9 but i don't think it matters
A friend of mine has Laser C v2.0 which has some AES examples in one
of the original disks! We tried to see what happens with 2 of these
examples, and we found out that the problem ALSO exists in both of them.
We also recompiled my program with Laser C, and nothing good happened!
This makes me think that it may be an undocumented AES bug(?).
On the other hand, all the programs i've seen using keyboard equi-
valents, do not have this problem!
The strange part is, that this is exactly what evnt_multi() is
supposed to do! When a menu is opened (but no entry has been selected)
the application sends NO message to the buffer..so evnt_multi() is
still active, waiting for a KEYBOARD or MENU event to occur! Thus if
a key is pressed, even if the menu is still opened, evnt_mutli()
writes the keyboard message to the buffer and terminates. ....And how
the heck am i supposed to change this behavior? How do the others do
it? You, guys, are my last hope! If i don't get any answer i'm gonna
remove the keyboard equivalents from the program (or i may leave it as
it is right now)...
Anyway, if someone out there knows the answer, PLEAAAAASEEEEE, let me
know........I may give him a free copy of my program (what a guy, he?)
And something else. What's your reaction on the file selector? Why am
I getting the file selector after the dialogue box? I cannot give any
logical explanation. I mean, i just talked about evnt_multi() and key-
equivalents..but why is it giving me the file selector? It should be
done after the dialogue box, right? (note that the file selector is
supposed to be activated with the entry 'Open', but still i cannot
explain it!)
thanks a lot!!!!
Harry Karayiannis
3rd Year Computer Science
Boston University
-------------------------------------- SORY FOR ANIE MISPELSS------------------
I'm just another Greek!!mui@atari.UUCP (Derek Mui) (12/13/89)
in article <138@bucsb.UUCP>, harryk@bucsb.UUCP (_harryk) says: > > Have I found an AES's bug or i don't know what i'm doing? > > Here is the problem: > > I'm writing an ST application which is supposed to use KEYBORD- > EQUIVALENTS for almost every entry of the menus. So, (naturaly?) > i'm using the function evnt_multi() in order to handle MESSAGE > and KEYBOARD events. The thing works ok except one annoying pro- > blem: > If i press a key-equivalent, while any of the pull-down > menus is open, i'm getting the action that corresponds to > that keyboard-equivalent( i.e using the mouse i open the 'File' > menu and i place the mouse pointer on the entry 'Open', which > is becoming "selected"....now, instead of clicking on 'Open', > I press Ctrl-A (which is the equivalent for 'About xxxx' under > the menu title 'Desk'). Well, what happens is that the dilogue > box for the 'About' selection appears on the screen; and after > I exit the dialogue box, i'm getting the file selector). The > correct response should be NEITHER dialogue-box NOR file selector! > > > The code i'm using is the following: > > > int dummy, keypressed, msg_buffer[8], event; > OBJECT *menutree; > > . > . > . > for(;;){ > menu_bar(menutree, 1); /* enable the menu bar */ > event = evnt_multi( MN_SELECTED | MU_KEYBD, > 0,0,0, /* clicks, button, state */ > 0, 0,0,0,0, /* inrec, x1, y1, w1, h1 */ > 0, 0,0,0,0, /* outrec,x2, y2, w2, h2 */ > msg_buffer, /* message buffer */ > dummy, dummy, /* lowtime, hightime */ > &dummy, &dummy, /* mouse coordinates */ > &dummy, &dummy, /* bptr, kptr */ > &keypressed, /* i want this one */ > &dummy /* times */ > ); > > menu_bar(menutree, 0); /* disable the menu bar */ > if ( event & MU_KEYBD ) > switch (keypressed){ > ........ > /* case quit: rsrc_free(); appl_exit(); exit(0); */ > } > else if (event & MN_SELECTED){ /* or just ... else */ > switch (msg_buffer[4]){ > ........ > /* case quit: rsrc_free(); appl_exit(); exit(0); */ */ > } > } /* for */ > > I don't exactly know what is going on in your program. But I could see there are some logical errors in the control loop. First of all, you should wait for event keyboard and event message ( MU_MESAG|MU_KEYBD ) in the evnt_multi(). However, your code suggest that you wait for Mouse Rectange 2 and Keyboard because you pass in ( MN_SELECTED|MU_KEYBD ) which has a value of 11 instead of 17. MN_SELECTED should not be used at here. After you regain control from the evnt_multi(), you need to check to see if the event is Message. If so, what kind of Message is it? The code should look something like this: menu_addr( menu, ON ); for( ; ; ) { event = evnt_multi( MU_MESAG|MU_KEYBD, 0,0,0, 0,0,0,0,0, 0,0,0,0,0, msg_buffer, dummy,dummy, &dummy,&dummy, &dummy,&dummy, &key, &dummy ); wind_update( TRUE ); /* block out everybody else */ if ( event & MU_KEYBD ) { do sonething.... } if ( event & MU_MESAG ) { if ( msg_buf[0] == MN_SELECTED )/* menu is selected */ { if ( msg_buf[3] == XXXXX ) /* check for which menu */ { if ( msg_buf[4] == YYYYY ) /* check for which item */ { do something .... } } } } wind_update( FALSE ); } menu_bar( menu, OFF ); appl_exit(); ----------------------------------------------------------- I hope this can help to clear up some of your confusions. Good Luck! Derek Mui Atari Corp Disclaimer: Opinions expressed here are my own.