Page 1 of 1

PostPosted: Fri Apr 06, 2001 6:40 pm
by Tom Miller
I could have sworn I saw this discussed, but I couldn't find it in the archives:

I finally decided to upgrade one of my programs to use menus -- make it more Palm-like. I wanted to make my own as opposed to using the "canned" packages out there, and am happy with the speed (instantaneous) of my menu response.

However, this meant that I had to figure out how PocketC is handling the menu events ("hookmenu") for OS3.5 machines, since there are two ways to invoke the menu. At first, it looked like PocketC just ignored the title bar tap, and the only way to invoke the menu was to tap on the menu silkscreen. As it turns out, PocketC DOES treat the title bar tap differently; it absorbs the pendown event so you can't trap it with, for example, "if(event(1)==2)"!

Seems like the easiest solution would have been for PocketC to assign the same event() return value for a tap on the title bar as for a tap on the menu silkscreen, but that's not how it works.

However, you can still trap this event by trapping the "penup". And this helps to differentiate from a tap elsewhere on the screen, because it does NOT start with a pendown.

Well, just had to get that off my chest -- I've been banging my head for the last couple of days.


PostPosted: Sat Apr 07, 2001 2:18 am
by Velvis
Would you mind showing the code? Someone before had added code to emulate the title bar tap behavior of 3.5, but when the applet first started the functionality was right until the menu button itself was pressed first.

PostPosted: Sat Apr 07, 2001 3:15 pm
by Tom Miller
It looks something like the following:

while(1){//event loop
if(e==1) do_keyboard_entry_routine();
do {} while(event(0)!=3);//trap pendown, but wait for penup. This traps ALL BUT a titlebar tap
if (e==3) do_menu_stuff();//penup -- this DOES trap the titlebar tap because PocketC sucked up the associated pendown, and all that's left of the event is the penup.
if (e==11) do_menu_stuff();

}//end of event loop
}//end main

I think that covers the essentials -- let me know if you have any questions.

Tom Miller