hotkey invlid in linux platform (wx3.0)

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Mon Jul 18, 2016 7:22 am

I try to update codes to wx3.0, now get a hotkey problem, it's ok on the windows platform, but on linux platform,
some hot keys are invalid,there has no response when i used hotkey in subwindow

example, subwindow menu : F , Shift+F ,Ctrl+F is ok, K, Ctrl+K ,I,F9,Shift+M ,Shift+C ... all invalid.
Firstly,I think, whether is dumplicate key caused,
i try to compare the submenu hotkey with main window hotkey,there has one key dumplicated, but other keys only used by once,
so i have no idea about it, Any one can provite some useful suggestions?

DavidHart
Site Admin
Site Admin
Posts: 3846
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: hotkey invlid in linux platform (wx3.0)

Post by DavidHart » Mon Jul 18, 2016 9:48 am

Hi,

Did those keys work in the subwindow menu on Linux before? If so, with which wx version? And are you using the same Linux distro and version now?

If the answers are Yes, how are you trying to catch the submenu events? Can you post the relevant bit of code?

Regards,

David

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Mon Jul 18, 2016 9:54 am

I found that, the subwindow has "Canvas::OnKeyDown(wxKeyEvent& event)" function, so only the eventkey which defined in this function are worked, the global hotkey event haven't worked.
how do i fixed this question?

wx2.8 to wx3.0 hotkey with wx2.8 is ok, 3.0 not worked in submenu on linux platform

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Mon Jul 18, 2016 10:04 am

DavidHart wrote:Hi,

Did those keys work in the subwindow menu on Linux before? If so, with which wx version? And are you using the same Linux distro and version now?

If the answers are Yes, how are you trying to catch the submenu events? Can you post the relevant bit of code?

Regards,

David
I found that, the subwindow has "Canvas::OnKeyDown(wxKeyEvent& event)" function, so only the eventkey which defined in this function are worked, the global hotkey event haven't worked.
how do i fixed this question?

wx2.8 to wx3.0 hotkey with wx2.8 is ok, 3.0 not worked in submenu on linux platform

DavidHart
Site Admin
Site Admin
Posts: 3846
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: hotkey invlid in linux platform (wx3.0)

Post by DavidHart » Mon Jul 18, 2016 10:25 am

Which distro are you using? Which version of it? Which Desktop Environment/Window manager are you using e.g. gnome, kde?
Were you using the same with wx2.8?
I found that, the subwindow has "Canvas::OnKeyDown(wxKeyEvent& event)" function, so only the eventkey which defined in this function are worked
That doesn't mean anything to us, as we cannot see your code. Please post the important bits of your code; the bits that show how you are trying to do the things that are failing.

User avatar
doublemax
Moderator
Moderator
Posts: 13738
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: hotkey invlid in linux platform (wx3.0)

Post by doublemax » Mon Jul 18, 2016 12:14 pm

You're talking about "hotkeys". Do you mean global hotkeys registered with RegisterHotKey() or do you mean "normal" keyboard shortcuts?
Use the source, Luke!

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Tue Jul 19, 2016 1:37 am

DavidHart wrote:Which distro are you using? Which version of it? Which Desktop Environment/Window manager are you using e.g. gnome, kde?
Were you using the same with wx2.8?
I found that, the subwindow has "Canvas::OnKeyDown(wxKeyEvent& event)" function, so only the eventkey which defined in this function are worked
That doesn't mean anything to us, as we cannot see your code. Please post the important bits of your code; the bits that show how you are trying to do the things that are failing.
I use wx 2.8.12 before, it's ok in windows and linux. now i updated it to wx 3.0.2, hotkey invalid in linux(gnome) at sub window.i think it's related to event processing.
global menu hotkey code:
main window is ok.
CAcceleratorKeyNode* file_menu=addMenu("&File");//File
file_menu->Append(FILE_NEW,"&New Workbook","Create a new workbook",'N',wxACCEL_CTRL);
subwindow not worked:
CAcceleratorKeyNode *view_menu = addMenu("&View");
view_menu->AppendCheckItem(VIEW_RULER, "&Ruler","Ruler",'K',wxACCEL_SHIFT);

because a panel( Canvas) in subwindow defined keyevent , when mouse focus on the Canvas, the global menu hotkey not worked, it go into the
canvas "Canvas::OnKeyDown(wxKeyEvent& event)" function
int keycode = event.GetKeyCode();
switch ( keycode )
{
case WXK_ESCAPE:
}
Last edited by jerome_mao on Tue Jul 19, 2016 5:40 am, edited 1 time in total.

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Tue Jul 19, 2016 1:55 am

doublemax wrote:You're talking about "hotkeys". Do you mean global hotkeys registered with RegisterHotKey() or do you mean "normal" keyboard shortcuts?
Hi ,i found the menu hotkey not worked in subwindow on linux platform( wx3.0.2) when the subwindow defined keyevent.
Canvas::OnKeyDown(wxKeyEvent& event)
Canvas::OnKeyUp(wxKeyEvent& event)
(windows OS is ok)
how to call the global hotkey event first?
Last edited by jerome_mao on Tue Jul 19, 2016 5:40 am, edited 1 time in total.

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Tue Jul 19, 2016 2:38 am

if focus to the other controls in the subwindow, the hotkey worked.
so just canvas(a panel) which defined keydown/keyup event, hotkey invalid.

DavidHart
Site Admin
Site Admin
Posts: 3846
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: hotkey invlid in linux platform (wx3.0)

Post by DavidHart » Tue Jul 19, 2016 9:30 am

I realise that English is not your first language, and that is making things harder for you as well as for us. But if you want help, you need to give us enough information for us to understand the problem. So far, that has not happened. You keep repeating the bits we already know, but don't give us the bits that we need.

To make it simple for both you and us, please provide a simple compilable program that shows the problem. The best way to do that is to make a diff to one of the wxWidgets samples (the ones that come with the wx source code) e.g. 'minimal' or 'menu'. Then we can test it ourselves and see what is going wrong, and why.

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Wed Jul 20, 2016 3:03 am

Hi DavidHart:
Thanks for your kindly help. Test Code:

Code: Select all

#include <wx/wx.h>


#define ID_OPENSUBWIN 1000
#define ID_EXITWIN 1001
#define ID_TIPWARNING 1002
#define ID_EXITSUBWIN 1003
class CSubPanel : public wxPanel
{
public:
	CSubPanel(wxWindow *parent);

	void OnKeyDown(wxKeyEvent &event);

	DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(CSubPanel, wxPanel)
EVT_KEY_DOWN(CSubPanel::OnKeyDown)
END_EVENT_TABLE()

CSubPanel::CSubPanel(wxWindow *parent) : wxPanel(parent, -1)
{

}

void CSubPanel::OnKeyDown(wxKeyEvent &event)
{
	int keycode = event.GetKeyCode();
	switch (keycode){
	case 'O':
		wxMessageBox("key event");
		break;
	default:
		break;
	}

	event.Skip();
}

class CSubWindow : public wxFrame
{
public:
	CSubWindow(wxWindow *parent);

	void OnMenu(wxCommandEvent& event);
	void OnClose(wxCloseEvent& event);

	DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(CSubWindow, wxFrame)
EVT_CLOSE(CSubWindow::OnClose)
EVT_MENU(ID_TIPWARNING, CSubWindow::OnMenu)
EVT_MENU(ID_EXITWIN, CSubWindow::OnMenu)
END_EVENT_TABLE()
CSubWindow::CSubWindow(wxWindow *parent) : wxFrame(parent, -1, wxT("SubWindow"), wxDefaultPosition, wxSize(600, 600))
{
	wxMenuBar *menubar = new wxMenuBar();
	wxMenu* fileMenu = new wxMenu;
	fileMenu->Append(ID_TIPWARNING, wxT("&Warning dlg\tO"));
	fileMenu->AppendSeparator();
	fileMenu->Append(ID_EXITSUBWIN, wxT("E&xit\tCtrl+Q"));
	menubar->Append(fileMenu, wxT("Window"));
	SetMenuBar(menubar);
	CSubPanel *panel = new CSubPanel(this);

	wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
	mainSizer->Add(panel, 1, wxEXPAND);

	SetSizer(mainSizer);
	SetAutoLayout(true);
}

void CSubWindow::OnMenu(wxCommandEvent& event)
{
	if (event.GetId() == ID_TIPWARNING)
	{
		wxMessageDialog dlg(this, "Tip Window");
		dlg.ShowModal();
	}
	else if (event.GetId() == ID_EXITSUBWIN)
	{
		this->Destroy();
	}

	event.Skip();
}

void CSubWindow::OnClose(wxCloseEvent& event)
{
	Destroy();
}

class CTestMainWindow :public wxFrame
{
public:
	CTestMainWindow(wxWindow* parent);
	void OnClose(wxCloseEvent& event);
	void OnMenu(wxCommandEvent& event);

	DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(CTestMainWindow, wxFrame)
EVT_CLOSE(CTestMainWindow::OnClose)
EVT_MENU(ID_OPENSUBWIN,CTestMainWindow::OnMenu)
EVT_MENU(ID_EXITSUBWIN, CTestMainWindow::OnMenu)
EVT_MENU(ID_TIPWARNING, CTestMainWindow::OnMenu)
END_EVENT_TABLE()

CTestMainWindow::CTestMainWindow(wxWindow* parent) : wxFrame(parent, -1, wxT("MainWindow"), wxDefaultPosition, wxSize(720,680))
{
	wxMenuBar *menubar = new wxMenuBar();
	wxMenu* fileMenu = new wxMenu;
	fileMenu->Append(ID_OPENSUBWIN, wxT("&Open..\tCtrl+O"));
	fileMenu->AppendSeparator();
	fileMenu->Append(ID_EXITWIN, wxT("E&xit\tCtrl+X"));
	menubar->Append(fileMenu, wxT("Window"));

	SetMenuBar(menubar);
}
void CTestMainWindow::OnClose(wxCloseEvent& event)
{
	Destroy();
}
void CTestMainWindow::OnMenu(wxCommandEvent& event)
{
	int evtid = event.GetId();
	if (evtid == ID_OPENSUBWIN)
	{
		CSubWindow* subwindow = new CSubWindow(this);
		subwindow->Show();
	}
	else if (evtid == ID_EXITWIN)
	{
		Destroy();
	}
	event.Skip();
}
class CTestApp : public wxApp
{
public:
	CTestApp();
	bool	OnInit(void);
	int	OnExit(void);

protected:
	
	CTestMainWindow *frame;

};
IMPLEMENT_APP(CTestApp)
CTestApp::CTestApp()
{

}

bool CTestApp::OnInit()
{
	frame = new CTestMainWindow(NULL);
	frame->CentreOnScreen(wxBOTH);
	frame->Show(TRUE);

	SetTopWindow(frame);

	return true;
}
int CTestApp::OnExit(void)
{
	return wxApp::OnExit();
}


wx3.0.2 subwindow hotkey( ID_TIPWARNING, ID_EXITSUBWIN)not work on linux os(redhat 6.3,centos 5.6)

DavidHart
Site Admin
Site Admin
Posts: 3846
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: hotkey invlid in linux platform (wx3.0)

Post by DavidHart » Wed Jul 20, 2016 5:46 pm

Thank you for posting the test-case. I've simplified it (the panel doesn't seem to need to be subclassed and, unless I'm still misunderstanding you, there is no need to confuse the issue with wxKeyEvents). Here is the updated version:

Code: Select all

#include <wx/wx.h>

#define ID_OPENSUBWIN 1000
#define ID_EXITWIN 1001
#define ID_TIPWARNING 1002
#define ID_K 10001
#define ID_SHK 10002
#define ID_CTLK 10003
#define ID_F 10004
#define ID_SHF 10005
#define ID_CTLF 10006
#define ID_F9 10007
#define ID_SHF9 10008
#define ID_CTLF9 10009
#define ID_EXITSUBWIN 1003

class CSubWindow : public wxFrame
{
public:
   CSubWindow(wxWindow *parent);

   void OnMenu(wxCommandEvent& event);
   void OnClose(wxCloseEvent& event);

   DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(CSubWindow, wxFrame)
    EVT_CLOSE(CSubWindow::OnClose)
    EVT_MENU(ID_TIPWARNING, CSubWindow::OnMenu)
    EVT_MENU_RANGE(ID_TIPWARNING, ID_CTLF9, CSubWindow::OnMenu)
END_EVENT_TABLE()

CSubWindow::CSubWindow(wxWindow *parent) : wxFrame(parent, -1, wxT("SubWindow"), wxDefaultPosition, wxSize(600, 600))
{
   wxMenuBar *menubar = new wxMenuBar();
   wxMenu* fileMenu = new wxMenu;
   fileMenu->Append(ID_TIPWARNING, wxT("&Warning dlg: O\tO"));
   fileMenu->Append(ID_K, wxT("K\tK"));
   fileMenu->Append(ID_SHK, wxT("SH-K\tShift-K"));
   fileMenu->Append(ID_CTLK, wxT("Ctrl-K\tCtrl-K"));
   fileMenu->Append(ID_F, wxT("F\tF"));
   fileMenu->Append(ID_SHF, wxT("SH F\tShift-F"));
   fileMenu->Append(ID_CTLF, wxT("CTL F\tCtrl-F"));
   fileMenu->Append(ID_F9, wxT("F9\tF9"));
   fileMenu->Append(ID_SHF9, wxT("SH F9\tShift-F9"));
   fileMenu->Append(ID_CTLF9, wxT("CTL F9\tCtrl-F9"));
   fileMenu->AppendSeparator();
   fileMenu->Append(ID_EXITSUBWIN, wxT("E&xit\tCtrl+Q"));
   menubar->Append(fileMenu, wxT("Window"));
   SetMenuBar(menubar);
   wxPanel *panel = new wxPanel(this);

   wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
   mainSizer->Add(panel, 1, wxEXPAND);

   SetSizer(mainSizer);
   SetAutoLayout(true);
}

void CSubWindow::OnMenu(wxCommandEvent& event)
{
   if (event.GetId() == ID_TIPWARNING)
   {
      wxMessageDialog dlg(this, wxT("Tip Window"));
      dlg.ShowModal();
   }
   else if (event.GetId() == ID_EXITSUBWIN)
   {
      this->Destroy();
   }
   else 
   {
      wxMessageDialog dlg(this, wxString::Format( wxT("ID %i pressed"), event.GetId()) );
      dlg.ShowModal();
   }

   event.Skip();
}

void CSubWindow::OnClose(wxCloseEvent& event)
{
   Destroy();
}

class CTestMainWindow :public wxFrame
{
public:
   CTestMainWindow(wxWindow* parent);
   void OnClose(wxCloseEvent& event);
   void OnMenu(wxCommandEvent& event);

   DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(CTestMainWindow, wxFrame)
    EVT_CLOSE(CTestMainWindow::OnClose)
    EVT_MENU(ID_OPENSUBWIN,CTestMainWindow::OnMenu)
    EVT_MENU(ID_EXITWIN, CTestMainWindow::OnMenu)
END_EVENT_TABLE()

CTestMainWindow::CTestMainWindow(wxWindow* parent) : wxFrame(parent, -1, wxT("MainWindow"), wxDefaultPosition, wxSize(720,680))
{
   wxMenuBar *menubar = new wxMenuBar();
   wxMenu* fileMenu = new wxMenu;
   fileMenu->Append(ID_OPENSUBWIN, wxT("&Open..\tO"));
   fileMenu->AppendSeparator();
   fileMenu->Append(ID_EXITWIN, wxT("E&xit\tCtrl+X"));
   menubar->Append(fileMenu, wxT("Window"));

   SetMenuBar(menubar);
}
void CTestMainWindow::OnClose(wxCloseEvent& event)
{
   Destroy();
}
void CTestMainWindow::OnMenu(wxCommandEvent& event)
{
   int evtid = event.GetId();
   if (evtid == ID_OPENSUBWIN)
   {
      CSubWindow* subwindow = new CSubWindow(this);
      subwindow->Show();
   }
   else if (evtid == ID_EXITWIN)
   {
      Destroy();
   }
   event.Skip();
}
class CTestApp : public wxApp
{
public:
   CTestApp();
   bool   OnInit(void);
   int   OnExit(void);

protected:
   
   CTestMainWindow *frame;
};
IMPLEMENT_APP(CTestApp)
CTestApp::CTestApp()
{
}

bool CTestApp::OnInit()
{
   frame = new CTestMainWindow(NULL);
   frame->CentreOnScreen(wxBOTH);
   frame->Show(TRUE);

   SetTopWindow(frame);

   return true;
}
int CTestApp::OnExit(void)
{
   return wxApp::OnExit();
}
I tested on debian jessie, kde, gtk+2, and fedora 24 gnome, gtk+3. I confirm that there is a difference between wx2.8 and wx3:
  • In 2.8 all keys are usable as menu shortcuts.

    Without the panel, all keys that I tested are usable as menu shortcuts.

    In both wx3.0.2 and git head, all the plain letter keys that I tested fail, and so do SHIFT-<letter>. However Ctrl-<letter> works, and so do the function keys e.g. F9, SHIFT-F9, Ctrl-F9.
I suppose this is a bug, especially as it works in wxMSW and it's a regression from wx2.8. However most people won't have an empty panel inside a child frame, and most people won't wish to use 'O' etc as menu shortcuts.
If you feel it should be reported though, bug-reports go to wxtrac.

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Thu Jul 21, 2016 1:46 am

Hi DavidHart:
Thanks a lot. Since the panel in example is a canvas in our real code. we defined lots of hotkeys to call the function.
And we defined keyevents in canvas. So, it seems that the keyevent cause menu hotkey not work in linux platform(wx3.0), i will reported it to the wxtrac ,hope it can be resolved as soon as possiable.

Code: Select all

void	Canvas::OnKeyDown(wxKeyEvent& event)
{
	if (m_drawDriver->GetBusyDrawing())
	{
		return;
	}

	double value;
	int keycode = event.GetKeyCode();
	switch ( keycode )
	{
	case WXK_ESCAPE:
		{
			if (m_status->getCurrentStatus()==STAT_SELECT_TRACE)
			{
				wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED, CMD_TRACE_SAMPLE_DONE);
				ev.SetString(wxString::Format("%d,%d", 0, 0));
				ev.SetInt(0);
				GetParent()->GetEventHandler()->ProcessEvent(ev);
			}
			else
			{
				stopAllThreads();
				wxCommandEvent ev(wxEVT_COMMAND_MENU_SELECTED,VIEW_NORMAL);
				GetParent()->GetEventHandler()->ProcessEvent(ev);
			}
			break;
		}
	case WXK_LEFT:
		value=m_drawDriver->m_virt_minX-m_drawDriver->m_virt_maxX;
		ScrollIt(m_drawDriver->getSettings()->getCanvasScrollRate()*value/20,false);
		break;
	case WXK_RIGHT:
		value=m_drawDriver->m_virt_maxX-m_drawDriver->m_virt_minX;
		ScrollIt(m_drawDriver->getSettings()->getCanvasScrollRate()*value/20,false);
		break;
	case WXK_DOWN:
		value=m_drawDriver->m_virt_minY-m_drawDriver->m_virt_maxY;
		ScrollIt(m_drawDriver->getSettings()->getCanvasScrollRate()*value/20,true);
		break;
		...
		}

DavidHart
Site Admin
Site Admin
Posts: 3846
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: hotkey invlid in linux platform (wx3.0)

Post by DavidHart » Thu Jul 21, 2016 9:19 am

So, it seems that the keyevent cause menu hotkey not work in linux platform(wx3.0)
No, it is not because of keyevents.

Try running the code I posted. It has no keyevents. You will find that 'O', 'F' etc do not work. Ctrl-O, Ctrl-F etc do work.

jerome_mao
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Jul 18, 2016 6:02 am

Re: hotkey invlid in linux platform (wx3.0)

Post by jerome_mao » Wed Jul 27, 2016 2:26 am

Hi:
I can't register trac account. It always tip the message like
"Warning: reCAPtCHA incorrect, Please try agian", but i can't find any reCAPTCHA info in the web.
http://trac.wxwidgets.org/login
Attachments
20160727101919.png
20160727101919.png (22.38 KiB) Viewed 1870 times

Post Reply