On Thu, 27 Jun 2002 12:04:27 -0600
Micah Dowty <[EMAIL PROTECTED]> wrote:

> On Thu, Jun 27, 2002 at 04:28:54PM +0200, [EMAIL PROTECTED] wrote:
> > Hi!
> > 
> > Although it seems, that I'm alone on this list I'm not too shy to ask
> 
> The list can be quiet.. there's usually more lively conversation in IRC
> :)
> 
> > another question. I'm in the process of porting a small editor MP,
> > 
> > http://www.triptoco.com
> > 
> > to PGUI. I have the problem, that this editor has dynamic menues. This
> > means, I need to make a menu, step by step, hide it and let it pop up,
> > if I press the button in the uppermost menubar. This is a wellknown
> > task in many other widget toolkits. The problem is, that PGUI does not
> > have such a "menu" widget. Maybe, this is not needed...
> > 
> > All the examples that come with PGUI seem to use hardcoded menues.
> > They work in that way, that they build up the menu at the time, where
> > a callback funtion is called. But this means, that the menu is
> > hardcoded in this function.
> 
> Actually, all menus are by nature dynamic in PicoGUI, most apps just use
> functions that build it all in one step, for convenience. You can use
> pgNewPopupAt to create a new popup widget, then add menuitems or
> whatever else.
> 
> > 
> > I now want to bring up a dynamic menu instead. Here is my try on a
> > generic callback function for all menues. It looks, from which Widget
> > it is called and decides then what menu to bring up. For now only a
> > box pops up:
> > 
> > int _mpv_menu_callback(struct pgEvent *evt)
> > /* menu click callback */
> > {
> >   pghandle result,toolbar;
> > 
> >   /* Do our own context management */
> >   pgEnterContext();
> > 
> >   /* Get the widget we come from */
> >   result = pgGetWidget(pgGetEvent()->from,PG_WP_TEXT);
> > 
> >   if (result)
> >     pgMessageDialogFmt("Menu results",0,
> >                        "You selected \"%s\"",
> >                        pgGetString(result));
> > 
> >   /* Clean-up time */
> >   pgLeaveContext();
> > 
> >   return 0;
> > 
> > }
> 
> I don't understand what this code is trying to do...

I have some other code - a button, that is clicked. It is one button, of a
menubar, like in many of the examples. All these buttoins have the above
function as callback function, with pgBind. My goal is to "see", which of
the 4 or five menu buttons had been clicked. If it is for example the
"File" button, I wish to find it out with the line: 

result = pgGetWidget(pgGetEvent()->from,PG_WP_TEXT);

Result should be a reference to the file button widget. Well, this is from
your mune example! Once I have this information, I want to call an
according menu, which a created before. But this may come later. First I
have to understand, how I can do the above thing.

> The pgEnterContext/pgLeaveContext in this function has no effect.

Well, I thought, that I did not really understand, what the are for. I
thought, I would need to free some memory I reserved. But you are right.
There is no.

> pgGetEvent() waits for a new event, but since you're already in an event
> handler there's an event in the "evt" parameter.

Ah, now that you say, now I understand the menu example. You build a menu,
and then the result line is waiting, till something is clicked (or an
other event happens). Ok. I misunderstood it, although ti is so simple...
:-|


> In this code, as soon as you create the menu it would be destroyed due
> to the pgLeaveContext right afterwards. You need to wait for an event,
> using a pgGetEvent loop or pgEventLoop/pgBind.

Ok, now I got it. I thought, the GetEvent would not wait, but just give
Information about the last happened event -> the one, from the above
clicked menu button. But it waits for the dropdown menus own button to
choose.

> > Thanks in advance...
> > --
> > Martin Doering

It did help!  :-)


-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel

Reply via email to