|
|
 | | From: | Edward Macnaghten | | Subject: | wxGTK: SetFocus after a wxMessageDialog not working | | Date: | Sat, 22 Jan 2005 01:47:14 +0000 (UTC) |
|
|
 | Please forgive me if this has been discussed and sorted before, just point me to the appropriate link.
SetFocus() does not work if you call it just before or after opening a wxMessageDialog. I have tried EVERYTHING (well nearly) trying to get this to function - even getting my hands dirty on the internals and calling gtk_widget_grab_focus(Window->GetHandle()) as well as wxWidget's SetFocus(), but still to no avail. Ihave tried defering the set focus and doing it as a result of an "AddPendingEvent" - no good!
The code works beutifully if the wxMessageDialog is not called - Focus goes where I want it - It also works perfectly on the wxMSW port (2000 and 2003) but simply refuses to in wxGTK.
Has anyone else had experience of this?
Eddy
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | Robert Roebling | | Subject: | Re: wxGTK: SetFocus after a wxMessageDialog not working | | Date: | Sat, 22 Jan 2005 10:31:05 +0000 (UTC) |
|
|
 | Edward Macnaghten wrote:
> Please forgive me if this has been discussed and sorted before, just > point me to the appropriate link. > > SetFocus() does not work if you call it just before or after opening a > wxMessageDialog.
The message dialog is a modal dialog so you cannot call SetFocus() to anything else. That is what the modality means. What are you trying to do?
Robert
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | Edward Macnaghten | | Subject: | Re: wxGTK: SetFocus after a wxMessageDialog not working | | Date: | Sat, 22 Jan 2005 17:32:38 +0000 (UTC) |
|
|
 | --------------080600060205020600080606 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit
I have written a small program that shows the problem.
Please note - this wotks fine under wxMSW - it just seems to be wxGTK that is messing about.
If you run it, a screen with two text controls appear, with the focus in the first. If you hit TAB a wxDialogMessage appears, but the focus stays in the first control. When you hot keys the characters appear there.
However, if you use the mouse and click on the second control, the same message appears, and it looks as though the focus has passed to the first control, bute when you press character keys the characters appear in the second control. If you examine the code you will see that should not be the case. On an EVT_SET_FOCUS on the second control I do a SetFocus on the first control, do a wxDialogMessage (and the ShowModal thereof), and do another SetFocus on the first control for good measure. The focus should NOT be still in the second control there.
Also, if you comment out the wxDialogMessage (and ShowModal) lines the message does not appear (of course), but the focus is in the first control regardless if you use the mouse or TAB key.
As I said, this only seems to go wrong on GTK (I have GTK 2.something - I do not know about GTK 1). It seems to work on wxMSW
Yours
Eddy
Robert Roebling wrote: > Edward Macnaghten wrote: > > >>Please forgive me if this has been discussed and sorted before, just >>point me to the appropriate link. >> >>SetFocus() does not work if you call it just before or after opening a >>wxMessageDialog. > > > The message dialog is a modal dialog so you cannot call > SetFocus() to anything else. That is what the modality > means. What are you trying to do? > > Robert > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org > For additional commands, e-mail: wx-users-help@lists.wxwidgets.org > > > >
--------------080600060205020600080606 Content-Type: text/plain; name="testmes.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="testmes.cpp"
#include #include #include
class MyApp : public wxApp { public: virtual bool OnInit(); };
class MyFrame : public wxFrame { public: MyFrame(wxString title); };
class MyText : public wxTextCtrl { public: MyText(wxWindow *win, int height); private: DECLARE_EVENT_TABLE(); void OnFocus(wxFocusEvent &event); };
class MyTextn : public wxTextCtrl { public: MyTextn(wxWindow *win, int height); };
IMPLEMENT_APP(MyApp)
BEGIN_EVENT_TABLE(MyText, wxTextCtrl) EVT_SET_FOCUS(MyText::OnFocus) END_EVENT_TABLE()
MyTextn *t1; // No focus events MyText *t2; // Focus event
bool MyApp::OnInit() { int i, j, k; MyFrame *frame = new MyFrame(wxString("Hello World")); wxPanel *pan = new wxPanel(frame, -1, wxDefaultPosition, wxSize(150, 150)); t1 = new MyTextn(pan, 30); t2 = new MyText(pan, 90);
t1->SetFocus();
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE; }
MyFrame::MyFrame(wxString title) : wxFrame((wxWindow *)NULL, -1, title, wxDefaultPosition, wxDefaultSize) { }
MyText::MyText(wxWindow *win, int pos) : wxTextCtrl(win, -1, "Hello", wxPoint(30, pos), wxSize(100, 30)) { }
void MyText::OnFocus(wxFocusEvent &event) { t1->SetFocus(); wxMessageDialog m(this, "Surprise!", "Boo!"); m.ShowModal(); t1->SetFocus(); }
MyTextn::MyTextn(wxWindow *win, int pos) : wxTextCtrl(win, -1, "Hello", wxPoint(30, pos), wxSize(100, 30)) { }
--------------080600060205020600080606 Content-Type: text/plain; charset=us-ascii
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org --------------080600060205020600080606--
|
|
 | | From: | Robert Roebling | | Subject: | Re: wxGTK: SetFocus after a wxMessageDialog not working | | Date: | Sun, 23 Jan 2005 16:05:22 +0000 (UTC) |
|
|
 | > Please note - this wotks fine under wxMSW - it just seems to be wxGTK > that is messing about.
What does "work fine" mean? You intercept the focus event of two text control and in the event handler, you set the focus to the first of the two. Do you want to veto a focus change or change the focus back after the dialog is shown?
> If you run it, a screen with two text controls appear, with the focus in > the first. If you hit TAB a wxDialogMessage appears, but the focus > stays in the first control. When you hot keys the characters appear there.
I assume that is expected.
> However, if you use the mouse and click on the second control, the same > message appears, and it looks as though the focus has passed to the > first control, bute when you press character keys the characters appear > in the second control. No, they appear in the first control. CVS from yesterday, GTK 2.2.3,
Robert
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | Edward Macnaghten | | Subject: | Re: wxGTK: SetFocus after a wxMessageDialog not working | | Date: | Sun, 23 Jan 2005 18:59:22 +0000 (UTC) |
|
|
 | Robert Roebling wrote: >>Please note - this wotks fine under wxMSW - it just seems to be wxGTK >>that is messing about. > > > What does "work fine" mean? You intercept the focus event > of two text control and in the event handler, you set the > focus to the first of the two. Do you want to veto a focus > change or change the focus back after the dialog is shown? >
The focus should be in the first control after the message
> >>If you run it, a screen with two text controls appear, with the focus in >>the first. If you hit TAB a wxDialogMessage appears, but the focus >>stays in the first control. When you hot keys the characters appear there. > > > I assume that is expected.
Yes
> > >>However, if you use the mouse and click on the second control, the same >>message appears, and it looks as though the focus has passed to the >>first control, bute when you press character keys the characters appear >>in the second control. > > > No, they appear in the first control. CVS from yesterday, GTK 2.2.3,
Is this Vwesion 2.4 or 2.5 of wxWidgets? If it is 2.5 - is that stable enough for a production environment?
> > Robert
Thanks for replying
Eddy
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | Xu, Ming (NIH/NLM/NCBI | | Subject: | use wxTipWindow issue | | Date: | Mon, 24 Jan 2005 04:36:26 +0000 (UTC) |
|
|
 | Hello.
I am trying to use wxTipWindow to prompt mouse pointer position (x,y). The problem is When I moved the mouse, the graph areas the mouse was dragged through were painted into light-grey. How can I avoid this. I guess that the setting of the tip window's background transparent may avoid the tip window to block the graph when mouse drags. Any suggetion about it.
thanks
ming
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | Robert Roebling | | Subject: | Re: wxGTK: SetFocus after a wxMessageDialog not working | | Date: | Sun, 23 Jan 2005 19:22:43 +0000 (UTC) |
|
|
 | > >>However, if you use the mouse and click on the second control, the same > >>message appears, and it looks as though the focus has passed to the > >>first control, bute when you press character keys the characters appear > >>in the second control. > > > > > > No, they appear in the first control. CVS from yesterday, GTK 2.2.3, > > Is this Vwesion 2.4 or 2.5 of wxWidgets? If it is 2.5 - is that stable > enough for a production environment?
I think that (with only a very incidents) wxGTK's CVS has been very stable and steadily improved. It certainly is better than any previous version. I'm currently having a bit of a problem with wxMSW from CVS, but wxMac and wxGTK should probably be used for "production" with a bit of appropriate caution. Robert
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
|
|
 | | From: | Robert Luchner | | Subject: | Re: wxGTK: SetFocus after a wxMessageDialog not working | | Date: | Sat, 22 Jan 2005 10:14:21 +0000 (UTC) |
|
|
 | --------------000607060808080100020302 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit
Edward Macnaghten schrieb:
> Please forgive me if this has been discussed and sorted before, just > point me to the appropriate link. > > SetFocus() does not work if you call it just before or after opening a > wxMessageDialog. I have tried EVERYTHING (well nearly) trying to get > this to function - even getting my hands dirty on the internals and > calling gtk_widget_grab_focus(Window->GetHandle()) as well as > wxWidget's SetFocus(), but still to no avail. Ihave tried defering > the set focus and doing it as a result of an "AddPendingEvent" - no good! > > The code works beutifully if the wxMessageDialog is not called - Focus > goes where I want it - It also works perfectly on the wxMSW port (2000 > and 2003) but simply refuses to in wxGTK. > > Has anyone else had experience of this? > > Eddy > > --------------------------------------------------------------------- > To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org > For additional commands, e-mail: wx-users-help@lists.wxwidgets.org > > Here is a sample, that work under WindowsXP with Borland very good!
--------------000607060808080100020302 Content-Type: text/x-cpp; name="EventHandler.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="EventHandler.cpp"
/* Projekt EventHandler (c) R. Luchner */
#include
#define ID_OFFSET 10000 #define ID_INPUT1 ID_OFFSET + 1 #define ID_INPUT2 ID_OFFSET + 2 #define ID_INPUT3 ID_OFFSET + 3
/***** Deklarationen *****/
class EventHandlerApp : public wxApp { public: virtual bool OnInit();
private: };
DECLARE_APP(EventHandlerApp)
class MyTextCtrl : public wxTextCtrl { public: MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); void OnChar(wxKeyEvent& event);
protected:
private: DECLARE_EVENT_TABLE()
};
class LogEventHandler : public wxEvtHandler { public: LogEventHandler(wxDialog *p); virtual ~LogEventHandler(){} void OnKeyDown(wxKeyEvent &event); void OnKillFocus(wxFocusEvent &event); void OnSetFocus(wxFocusEvent &event);
protected:
private: wxDialog* mThisframe;
DECLARE_EVENT_TABLE() };
class EventHandlerDialog : public wxDialog { public: EventHandlerDialog(wxWindow *parent, int id, const wxString& title); void OnClose(wxCommandEvent &event); void OnTextEnter(wxCommandEvent &event);
long feld; MyTextCtrl *input1; MyTextCtrl *input2; MyTextCtrl *input3;
protected:
private: // ID enum { EVENT_DLG_CLOSE = 1000 };
wxButton *closeButton; wxEvtHandler* mKeyEvent;
DECLARE_EVENT_TABLE() };
/***** Implementierung *****/
IMPLEMENT_APP(EventHandlerApp)
bool EventHandlerApp::OnInit() { /* Einsprungpunkt */ EventHandlerDialog *dlg = new EventHandlerDialog( (wxWindow *)NULL, -1, "EventHandlerDialog");
SetTopWindow(dlg); dlg->Show(true); return(true); }
MyTextCtrl::MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) : wxTextCtrl(parent, id, value, pos, size, style, validator, name) { }
void MyTextCtrl::OnChar(wxKeyEvent& event) { char ch;
ch = event.GetKeyCode(); // alle erlaubter Zeichen (links, rechts, Backspace... // eventuell Dezimalkomma in Dezimalpunkt... if (isdigit(ch) | (ch == '.' )) { event.Skip(); } else { // Zeichen nicht erlaubt! wxBell(); } }
BEGIN_EVENT_TABLE(MyTextCtrl, wxTextCtrl)
EVT_CHAR(MyTextCtrl::OnChar)
END_EVENT_TABLE()
LogEventHandler::LogEventHandler(wxDialog* p) { mThisframe = p; }
void LogEventHandler::OnKeyDown(wxKeyEvent& event) { // Taste dekodieren eventuell andere Felder aktivieren - Schleife EventHandlerDialog* myDialog = (EventHandlerDialog*)mThisframe; switch(event.GetKeyCode()) { case WXK_NEXT: if (myDialog->feld < 3) myDialog->feld++; else myDialog->feld = 1; break;
case WXK_PRIOR: if (myDialog->feld > 0) myDialog->feld--; else myDialog->feld = 3; break;
case WXK_RETURN: case WXK_NUMPAD_ENTER: case WXK_TAB: if (myDialog->feld < 3) myDialog->feld++; else myDialog->feld = 1; break; } switch (myDialog->feld) { case 1: myDialog->input1->SetFocus(); break;
case 2: myDialog->input2->SetFocus(); break;
case 3: myDialog->input3->SetFocus(); break; } event.Skip(); }
void LogEventHandler::OnKillFocus(wxFocusEvent& event) { EventHandlerDialog* myDialog = (EventHandlerDialog*)mThisframe;
// Alle Berechungen event.Skip(); }
void LogEventHandler::OnSetFocus(wxFocusEvent& event) { EventHandlerDialog* myDialog = (EventHandlerDialog*)mThisframe; myDialog->feld = ((wxWindow*)event.m_eventObject)->GetId() - ID_OFFSET; }
BEGIN_EVENT_TABLE(LogEventHandler, wxEvtHandler)
EVT_KEY_DOWN(LogEventHandler::OnKeyDown) EVT_KILL_FOCUS(LogEventHandler::OnKillFocus) EVT_SET_FOCUS(LogEventHandler::OnSetFocus)
END_EVENT_TABLE()
EventHandlerDialog::EventHandlerDialog(wxWindow *parent, int id, const wxString& title) : wxDialog(parent, id, title) { closeButton = new wxButton(this, EVENT_DLG_CLOSE, _T("Close"), wxDefaultPosition);
wxStaticText *label1 = new wxStaticText(this, -1, "Eingabe 1:"); input1 = new MyTextCtrl(this, ID_INPUT1, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); wxStaticText *label2 = new wxStaticText(this, -1, "Eingabe 2:"); input2 = new MyTextCtrl(this, ID_INPUT2, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); wxStaticText *label3 = new wxStaticText(this, -1, "Eingabe 3:"); input3 = new MyTextCtrl(this, ID_INPUT3, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
mKeyEvent = new LogEventHandler(this);
input1->PushEventHandler(mKeyEvent); input2->PushEventHandler(mKeyEvent); input3->PushEventHandler(mKeyEvent);
wxBoxSizer *dlgSizer = new wxBoxSizer(wxVERTICAL);
wxGridSizer *inputSizer = new wxGridSizer(1, 2, 0, 0);
inputSizer->Add(label1, 0, wxALIGN_CENTRE_VERTICAL); inputSizer->Add(input1, 0, wxALIGN_CENTRE_VERTICAL);
inputSizer->Add(label2, 0, wxALIGN_CENTRE_VERTICAL); inputSizer->Add(input2, 0, wxALIGN_CENTRE_VERTICAL);
inputSizer->Add(label3, 0, wxALIGN_CENTRE_VERTICAL); inputSizer->Add(input3, 0, wxALIGN_CENTRE_VERTICAL);
wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); buttonSizer->Add(closeButton, 0, wxALIGN_CENTER);
dlgSizer->Add(inputSizer, 1, wxALIGN_CENTER); dlgSizer->Add(buttonSizer, 1, wxALIGN_CENTER);
input1->SetFocus();
SetSizer(dlgSizer); SetAutoLayout(TRUE); Layout(); }
void EventHandlerDialog::OnClose(wxCommandEvent &event) { Destroy(); }
void EventHandlerDialog::OnTextEnter(wxCommandEvent &event) { wxMessageBox("RETURN Taste: Dialog-Klasse"); }
BEGIN_EVENT_TABLE(EventHandlerDialog, wxDialog)
EVT_BUTTON(EVENT_DLG_CLOSE, EventHandlerDialog::OnClose) EVT_CLOSE(EventHandlerDialog::OnClose)
END_EVENT_TABLE()
--------------000607060808080100020302 Content-Type: text/plain; charset=us-ascii
--------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org For additional commands, e-mail: wx-users-help@lists.wxwidgets.org --------------000607060808080100020302--
|
|
|