🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #6906

Re: AES bug?

#6906
From: Derek Mui
Date: Tue, 12 Dec 1989 19:12
131 lines
4792 bytes
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.
Technical Details
Message-ID: <1877@atari.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!think!ames!sun-barr!newstop!sun!imagen!atari!mui
References: <138@bucsb.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!think!ames!sun-barr!newstop!sun!imagen!atari!mui
From: mui@atari.UUCP (Derek Mui)
Newsgroups: comp.sys.atari.st
Subject: Re: AES bug?
Message-ID: <1877@atari.UUCP>
Date: 12 Dec 89 19:12:46 GMT
References: <138@bucsb.UUCP>
Organization: Atari Corp., Sunnyvale CA
Lines: 131