event id of a disabled button

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ebe
Earned a small fee
Earned a small fee
Posts: 20
Joined: Thu Mar 22, 2012 7:18 am

event id of a disabled button

Post by ebe »

hi masters,

Here i face some problem in getting an ID of a disabled button, by right clicking over on it.
I used context menu event, but i got the panel id only where the button has been created over it.
Please give some suggestion for it.

Thanks in Advance,
Ebe
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: event id of a disabled button

Post by Auria »

Please share some code
"Keyboard not detected. Press F1 to continue"
-- Windows
Nelson Joseph
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sun Oct 26, 2008 5:15 am
Location: Chennai, India
Contact:

Re: event id of a disabled button

Post by Nelson Joseph »

Hi Ebe:

wxWindowID theId = myDisabledButton->GetId();
Regards,
Nelson Joseph
ebe
Earned a small fee
Earned a small fee
Posts: 20
Joined: Thu Mar 22, 2012 7:18 am

Re: event id of a disabled button

Post by ebe »

Auria wrote:Please share some code
Sure!..Auria..

Code: Select all

{
oneButton	= new wxBitmapButton( m_pTopLeftPanel,  wxID_BUTTON_1,  wxBitmap( wxT(""),wxBITMAP_TYPE_PNG ),wxDefaultPosition, MAXBUTTONSIZE,wxBU_EXACTFIT,wxDefaultValidator);
oneButton	->SetLabel(wxT("1"));
oneButton->Disable();
twoButton	= new wxBitmapButton( m_pTopLeftPanel,  wxID_BUTTON_2,  wxBitmap( wxT(""),wxBITMAP_TYPE_PNG ),wxDefaultPosition, MAXBUTTONSIZE,wxBU_EXACTFIT,wxDefaultValidator);
twoButton	->SetLabel(wxT("2"));
twoButton->Disable();
threeButton= new wxBitmapButton( m_pTopLeftPanel,  wxID_BUTTON_3,  wxBitmap( wxT(""),wxBITMAP_TYPE_PNG ),wxDefaultPosition, MAXBUTTONSIZE,wxBU_EXACTFIT,wxDefaultValidator);
threeButton->SetLabel(wxT("3"));
threeButton->Disable();
fourButton	= new wxBitmapButton( m_pTopLeftPanel,  wxID_BUTTON_4,  wxBitmap( wxT(""),wxBITMAP_TYPE_PNG ),wxDefaultPosition, MAXBUTTONSIZE,wxBU_EXACTFIT,wxDefaultValidator);
fourButton	->SetLabel(wxT("4"));
fiveButton	= new wxBitmapButton( m_pTopLeftPanel,  wxID_BUTTON_5,  wxBitmap( wxT(""),wxBITMAP_TYPE_PNG ),wxDefaultPosition, MAXBUTTONSIZE,wxBU_EXACTFIT,wxDefaultValidator);
fiveButton	->SetLabel(wxT("5"));
}
//context menu
{
int eventID = event.GetId();
wxMenu* menu = new wxMenu;
menu->Append( wxID_FORCETOEDIT, wxT( "&Edit" ));

if( eventID == wxID_BUTTON_1 && !oneButton->IsEnabled())
	PopupMenu( menu, wxDefaultPosition );
else if( eventID == wxID_BUTTON_2 && !twoButton->IsEnabled())
	PopupMenu( menu, wxDefaultPosition );
else if( eventID == wxID_BUTTON_3 && !threeButton->IsEnabled())
	PopupMenu( menu, wxDefaultPosition );
else if( eventID == wxID_BUTTON_4 && !fourButton->IsEnabled())
	PopupMenu( menu, wxDefaultPosition );
else if( eventID == wxID_BUTTON_5 && !fiveButton->IsEnabled())
              PopupMenu( menu, wxDefaultPosition );
}
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: event id of a disabled button

Post by Auria »

okay but how do you catch the right click, and also which code do you execute on right-clicks that tries to get the event (if I understood correctly)
"Keyboard not detected. Press F1 to continue"
-- Windows
ebe
Earned a small fee
Earned a small fee
Posts: 20
Joined: Thu Mar 22, 2012 7:18 am

Re: event id of a disabled button

Post by ebe »

Auria wrote:okay but how do you catch the right click, and also which code do you execute on right-clicks that tries to get the event (if I understood correctly)
thanks for ur quick reply.. here iam using (wxContextMenuEvent& event).
while i right click over the enabled button i can popup a context menu by getting the event id,
but my need is to popup a context menu over the disabled button by getting the id of which button the mouse is over on.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: event id of a disabled button

Post by Auria »

instead of using context menu events, I suggest just using a regular wxMouseEvent with EVT_RIGHT_DOWN
"Keyboard not detected. Press F1 to continue"
-- Windows
ebe
Earned a small fee
Earned a small fee
Posts: 20
Joined: Thu Mar 22, 2012 7:18 am

Re: event id of a disabled button

Post by ebe »

Auria wrote:instead of using context menu events, I suggest just using a regular wxMouseEvent with EVT_RIGHT_DOWN
yes..! i tried that.
Since the button is already disabled, I could not capture EVT_RIGHT_DOWN event.
Post Reply