bug with menu events !!!

Questions about wxWidgets running on MS.NET, mono or Portable.NET ? Ask it here !
Post Reply
manu123456
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Apr 04, 2005 12:51 pm

bug with menu events !!!

Post by manu123456 »

hi
I have a problem with wx.net 0.6.0.1
I would like to know the sender of a menu event when I click on the menuitem.
It's the wx.frame who's return and not the wx.menuitem !

why ???

For exemple :

public class Form1 : wx.Frame {
private wx.MenuBar mainMenu1;
private wx.Menu menuItem1;
const int ID_MENUITEM1 = 1;

public Form1() : this("Form1", wx.Window.wxDefaultPosition, new System.Drawing.Size(300,321))
{
mainMenu1=new wx.MenuBar();
menuItem1=new wx.Menu();
menuItem1.Append(ID_MENUITEM1, "Test");
this.MenuBar=mainMenu1;

EVT_MENU(ID_MENUITEM1, new wx.EventListener(this.menuItem1_Click));

}

private void menuItem1_Click(object sender, wx.Event e)
{
}
}


the sender of "menuItem1_Click" is still "FORM1" but it should be "MENUTITEM1" !!!!!!!!

I'm right ?????

What is a problem ????

Thanks for your help !!!!

Manu
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton »

Maybe wx.Net does something differently, but AFAIK menu select events don't send the corresponding menu along with them.

You can use e.GetId() to get the id of the menu item though
[Mostly retired moderator, still check in to clean up some stuff]
manu123456
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Apr 04, 2005 12:51 pm

Post by manu123456 »

it's the ID of the form who's returned :(((

thanks for your help
nummish
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Jan 07, 2005 6:24 pm
Contact:

Post by nummish »

you have the Form's ID automatically generated, but are defining the menu's ID as a constant. Try using the Window.UniqueID() method to generate a unique one (this.UniqueID in this case iirc)
manu123456
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Apr 04, 2005 12:51 pm

Post by manu123456 »

this goes perfectly
thank you very much nummish
Post Reply