keyongtech


  keyongtech > mac.programmer.help > 07/2003

 #1  
07-24-03, 01:07 PM
David Scrève
Hello,

Has anybody successfully created a dynamic popup menu control (ie, without relying on Menu resource) ? I have some problems with
the following code:

Rect controlRect = {10,10,260,300};
ControlRef mControlRef;
MenuRef mMenuRef;


mControlRef=NewControl(outWindow,&controlRect,NULL ,true,0,-12345,0,kControlPopupButtonProc+kControlPopupFixed WidthVariant,(SInt32)NU
LL);
Boolean bCheckCurrentTag;

CreateNewMenu((MenuID)4096,0,&mMenuRef);

AppendMenuItemText(mMenuRef, "\pItem #1");
AppendMenuItemText(mMenuRef, "\pItem #2");
AppendMenuItemText(mMenuRef, "\pItem #3");

bCheckCurrentTag=true;
SetControlData(mControlRef,kControlEntireControl ,kControlPopupButtonMenuRefTag,sizeof(mMenuRef),&m MenuRef);
SetControlData(mControlRef,kControlEntireControl ,kControlPopupButtonCheckCurrentTag,sizeof(bCheckC urrentTag),&bCheckCurrentTag);


The control is properly created, the menu is properly clickable, but the control never shows the current selection : It only shows
an empty text ??

Is there something missing ? And how can I track when the selection change ?

Thanks for your help,

David
 #2  
07-24-03, 04:10 PM
Tom Dowdy
In article <3f1fcc1f$0$15337$626a54ce>,
"David Scrève" <dscreve> wrote:
[..]
> ,kControlPopupButtonMenuRefTag,sizeof(mMenuRef),&m MenuRef);
> SetControlData(mControlRef,kControlEntireControl
> ,kControlPopupButtonCheckCurrentTag,sizeof(bCheckC urrentTag),&bCheckCurrentTa
> g);
>
> The control is properly created, the menu is properly clickable, but the
> control never shows the current selection : It only shows
> an empty text ??
>
> Is there something missing ?


Yes.

InsertMenu(mMenuRef, -1);
SetControlMaximum(mControlRef, CountMItems(mMenuRef));

> And how can I track when the selection change ?


When you've tracked the control, call GetControlValue() to see what the
user has selected.
 #3  
07-28-03, 07:32 PM
Tom Dowdy
In article <BB4B240F9668192C1>,
hitman (Graham Hinton) wrote:
> Following on from that, how are you supposed to find what the selection is
> with hierarchical menus?
> GetControlValue returns the top menu item. GetControData() does not seem to
> have the right information anywhere.


Hmmm, don't know this one. I've never used hierarchical menus from a
popup. Sounds like iffy UI, but if you need to, you need to.

> Also, how do you change a menu item in a control? I tried
> SetMenuItemText(), but nothing changed. Does the control have its own copy?


You *can* change the item. However, you can only do so if you have
created and installed the menu yourself PRIOR to creation of the
control. If you let the control load the menu resource, then yes, it
"has a copy" (not really, but for all itents and purposes it might as
well).
 #4  
07-29-03, 09:53 AM
Graham Hinton
In article <dowdy-342420.11325428072003>,
Tom Dowdy <dowdy> wrote:

>Hmmm, don't know this one. I've never used hierarchical menus from a
>popup.


There is an example in Appearance SDK from a bevel button, but it is all
show and no blow.

> Sounds like iffy UI, but if you need to, you need to.


Better than a menu the full height of the screen...
The iffy part is all these controls that half work and are not properly
documented.


>You *can* change the item. However, you can only do so if you have
>created and installed the menu yourself PRIOR to creation of the
>control. If you let the control load the menu resource, then yes, it
>"has a copy" (not really, but for all itents and purposes it might as
>well).


Both the control and original menu are resources. Can I still have them as
resources and satisfy that condition? ie don't have the miniumum value
pointing to the menu and then install the menu by program?
 #5  
07-29-03, 04:05 PM
Tom Dowdy
In article <BB4BF4AE9668BC8D>,
hitman (Graham Hinton) wrote:
> >You *can* change the item. However, you can only do so if you have
> >created and installed the menu yourself PRIOR to creation of the
> >control. If you let the control load the menu resource, then yes, it
> >"has a copy" (not really, but for all itents and purposes it might as
> >well).

>
> Both the control and original menu are resources. Can I still have them as
> resources and satisfy that condition? ie don't have the miniumum value
> pointing to the menu and then install the menu by program?


Yes, however if you want to be able to change the menu contents (either
on the fly during the dialog/window, or prior to running it) you need to
install it yourself prior to instantiating the control.

Actually, it doesn't matter if you have the minimum value or not. If
the menu is already in the menu bar, the control assumes you (the app)
are managing the content.
Similar Threads
placement of dynamic control depends on VALUE of dynamic control

A dynamic control (A dropdown) is created in PageLoad, but the value of the dynamic control dictates where it's added (such as which cell in a table) on a postback. Seems...

Dynamic Events from Dynamic Controls on a User Control - Guess What? Broken!

Hi, Hope you can help. I am relatively new to all this but would appreciate the groups help. The scenario: I am c# and asp.net to create a web application. The web page...

dynamic popup

Hi, I have two buttons calling the same funtion to open a popup window, dinamically built according to parameters passed to the function. The problem: when I click the first...

Dynamic popup list

Hi all, I got 2 set of list item and want to assign to a popup trigger dynamically. Those 2 set of list are pre define in resources. But I look at the API doc, it said I am...

Repeater, Panel, dynamic user control - can't retrieve dynamic controls in code behind

I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires...


All times are GMT. The time now is 04:56 PM. | Privacy Policy