|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
treeview Tab controlDear all,
I am desperately trying to get the following behavior to work in a treevew. The treeview entierly consists of rows with editable text cells. If I am editing a cell and hit the TAB button I want the treeview to store the actual changes and move on to the next column. I think I have to work with the cellrenderertext but let me tell you first what i tried this far. - I connected to button_pressed with the treeview. In principle this seems to work. At least I can catch the tab key and set the cursor position to the next column. But the changes in the previous cell are lost - I managed to get a hold on to the active cell renderer. Then I tried to read the value of the active cell (which is not stored in the treestore jet) doing something like this: cellrenderertext* -> gobj() -> text. But here the compiler tells me something like class _GtkCellRendererText not completely defined. According to gtk/gtkcellrenderer.h its a struct though. - Next thing I thought I could send the cellrenderer the signal that I hit return. But here I did not find a solution. So does any of you have a solution. Writing my own cellrenderer does not seem to be the best way as I only get a hold of the has_changed signal. So I first have to hit return before my own version get's active. Thanks a lot Thomas -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlHi everyone,
does really nobody has even the smallest hint for me? I simply want the tab-key in an editable treeview to behave like the return-key. I would really appreciate it. Thomas -------- Original-Nachricht -------- > Datum: Wed, 28 Oct 2009 17:52:23 +0100 > Von: "Thomas Sommer" <mawa15@...> > An: gtkmm-list@... > Betreff: treeview Tab control > Dear all, > > I am desperately trying to get the following behavior to work in a > treevew. > The treeview entierly consists of rows with editable text cells. > If I am editing a cell and hit the TAB button I want the treeview to store > the actual changes and move on to the next column. > > I think I have to work with the cellrenderertext but let me tell you first > what i tried this far. > > - I connected to button_pressed with the treeview. > In principle this seems to work. At least I can catch the tab key and > set > the cursor position to the next column. But the changes in the previous > cell are lost > > - I managed to get a hold on to the active cell renderer. > Then I tried to read the value of the active cell (which is not stored > in > the treestore jet) doing something like this: > cellrenderertext* -> gobj() -> text. > But here the compiler tells me something like class _GtkCellRendererText > not completely defined. According to gtk/gtkcellrenderer.h its a struct > though. > > - Next thing I thought I could send the cellrenderer the signal that I > hit return. But here I did not find a solution. > > So does any of you have a solution. Writing my own cellrenderer does not > seem to be the best way as I only get a hold of the has_changed signal. So I > first have to hit return before my own version get's active. > > Thanks a lot > > Thomas > > -- > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 > _______________________________________________ > gtkmm-list mailing list > gtkmm-list@... > http://mail.gnome.org/mailman/listinfo/gtkmm-list -- Neu: GMX DSL bis 50.000 kBit/s und 200,- Euro Startguthaben! http://portal.gmx.net/de/go/dsl02 _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlOn Sat, 2009-10-31 at 09:45 +0100, Thomas Sommer wrote:
> Hi everyone, > > does really nobody has even the smallest hint for me? > I simply want the tab-key in an editable treeview to behave like the > return-key. > > I would really appreciate it. The section in the online book on "Editable Cells"[1] may give you ideas as to how to go about achieving what you're trying to do. [1] http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-treeview.html.en#treeview-editable-cells -- José _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlHi, Thomas.
Maybe you should try to catch GDK events ? Like this: // in constructor signal_key_press_event().connect(sigc::mem_fun(*this, &MyTreeView::onKeyPressEvent), false); /// ............. bool MyTreeView::onKeyPressEvent(GdkEventKey* event) { if(event->type == GDK_KEY_PRESS) { if(event->keyval == GDK_Return) { // set active next column // ... // and stop executing of other handlers return true; } } return false; } If your gdk event handler returns true, all other handlers won't be executed. GDK_Return represents "Enter" key, you should replace it with GDK_Tab (but i'm not sure, look at gtkmm header files). Galymzhan. 2009/11/2, José Alburquerque <jaalburquerque@...>: > On Sat, 2009-10-31 at 09:45 +0100, Thomas Sommer wrote: >> Hi everyone, >> >> does really nobody has even the smallest hint for me? >> I simply want the tab-key in an editable treeview to behave like the >> return-key. >> >> I would really appreciate it. > > The section in the online book on "Editable Cells"[1] may give you ideas > as to how to go about achieving what you're trying to do. > > [1] > http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-treeview.html.en#treeview-editable-cells > > -- > José > > _______________________________________________ > gtkmm-list mailing list > gtkmm-list@... > http://mail.gnome.org/mailman/listinfo/gtkmm-list > gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlThat's exactly what I tried before:
bool gui::key_pressed(GdkEventKey* event) { if(event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab) { Gtk::TreeModel::iterator iter = m_refTreeSelection_TreeView->get_selected(); Gtk::TreeModel::Path p; Gtk::TreeViewColumn* c; m_pTreeView->get_cursor(p,c); if(c==m_pTreeView_OPL->get_column(0)) m_pTreeView_OPL-> set_cursor(m_refModel_TreeView->get_path(iter), *(m_pTreeView->get_column(1)),true); } return true; } Problem is: Hittin tab will set the cursors to the second column but the entry in the editable gets lost. Restoring it to the value stored in the TreeStore. Therefore I tried to get a hold of the cellrenderer Gtk::CellRenderer* r=m_pTreeView->get_column_cell_renderer (0); Gtk::CellRendererText* t=dynamic_cast<Gtk::CellRendererText*>(r); and tried to emit the changed signal. Sadly the emit() funktion does not exist ;-( t->signal_edited().emit(); I know this is a bad idea but doing something like this would be much easier than writing my own cellrenderer (I think). I read something about calling the signal handler instead of emitting the signal myself. But how do I call the signal handler of the celleditable? Thanks, Thomas -------- Original-Nachricht -------- > Datum: Mon, 2 Nov 2009 14:35:36 +0600 > Von: "Галымжан Кожаев" <kozhayev@...> > An: "José Alburquerque" <jaalburquerque@...> > CC: Thomas Sommer <mawa15@...>, gtkmm-list@... > Betreff: Re: treeview Tab control > Hi, Thomas. > Maybe you should try to catch GDK events ? Like this: > > // in constructor > signal_key_press_event().connect(sigc::mem_fun(*this, > &MyTreeView::onKeyPressEvent), false); > > /// ............. > bool MyTreeView::onKeyPressEvent(GdkEventKey* event) { > if(event->type == GDK_KEY_PRESS) { > if(event->keyval == GDK_Return) { > // set active next column > // ... > // and stop executing of other handlers > return true; > } > } > return false; > } > > If your gdk event handler returns true, all other handlers won't be > executed. GDK_Return represents "Enter" key, you should replace it > with GDK_Tab (but i'm not sure, look at gtkmm header files). > > Galymzhan. > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlHi all,
for the cellrenderer I just found editing_canceled() here the hack into the editable treeview example from the docs: bool ExampleWindow::on_key_press(GdkEventKey* event) { std::cout << event->keyval << "\n"; Gtk::CellRenderer* r=m_TreeView.get_column_cell_renderer (0); r->editing_canceled(); } I get the key value but editing is not canceled when hitting tab in the first column. Do I select the wrong renderer? Thomas -- Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 - sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlOn Wed, 2009-11-04 at 18:48 +0100, Thomas Sommer wrote:
> Hi all, > > for the cellrenderer I just found editing_canceled() > > here the hack into the editable treeview example from the docs: > > bool ExampleWindow::on_key_press(GdkEventKey* event) > { > std::cout << event->keyval << "\n"; > Gtk::CellRenderer* r=m_TreeView.get_column_cell_renderer (0); > r->editing_canceled(); > } > > I get the key value but editing is not canceled when hitting tab in the > first column. > Do I select the wrong renderer? Maybe if you provide a minimal test case we can run it and see what the problem is. My guess would be that editing should work out of the box (without the need for special code). From reading the book, I get the impression that if you use the [insert/append]_column_editable() methods of the TreeView things should work correctly, but I could be wrong. -- José _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlHi Jose,
you will find the hacked treeview from the gtkmm examples in the attachment. Basically all I did was attaching on_key_press() to signal_key_pressed. Funny thing tough: If I add the column m_TreeView.get_columns(); to the attached function, everything works as I would expect it. It just does not seem to make any sense to me. Many thanks for your effort. Thomas -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlOn Wed, 2009-11-04 at 22:03 +0100, Thomas Sommer wrote:
> Hi Jose, > > you will find the hacked treeview from the gtkmm examples in the attachment. > > Basically all I did was attaching on_key_press() to signal_key_pressed. > Funny thing tough: If I add the column > > m_TreeView.get_columns(); > > to the attached function, everything works as I would expect it. > It just does not seem to make any sense to me. It doesn't make sense to me either. What I would suggest is that you guide yourself from the example that you hacked. On this system the example works fine (with tabs, etc.) as you also want. I can't tell definitely but, once more, my guess would be that if you handle key presses, I don't think that you need to pay special attention to the tab key. This is just a guess as I'm going by how the original example works on this system. -- José _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlHi, Thomas!
You wrote that hitting Tab erases cell, restoring it to value stored in TreeStore. What if you will somehow get the text in edited column and manually set the value in TreeStore using that key_pressed handler? I think text is getting lost because treeview displays data in model (in our case treestore), am I right ? 2009/11/5, José Alburquerque <jaalburquerque@...>: > On Wed, 2009-11-04 at 22:03 +0100, Thomas Sommer wrote: >> Hi Jose, >> >> you will find the hacked treeview from the gtkmm examples in the >> attachment. >> >> Basically all I did was attaching on_key_press() to signal_key_pressed. >> Funny thing tough: If I add the column >> >> m_TreeView.get_columns(); >> >> to the attached function, everything works as I would expect it. >> It just does not seem to make any sense to me. > > It doesn't make sense to me either. What I would suggest is that you > guide yourself from the example that you hacked. On this system the > example works fine (with tabs, etc.) as you also want. I can't tell > definitely but, once more, my guess would be that if you handle key > presses, I don't think that you need to pay special attention to the tab > key. This is just a guess as I'm going by how the original example > works on this system. > > -- > José > > _______________________________________________ > gtkmm-list mailing list > gtkmm-list@... > http://mail.gnome.org/mailman/listinfo/gtkmm-list > gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: treeview Tab controlTotally correct,
problem is: I just don't know how to get the value in the editable. That's what I tried: bool ExampleWindow::on_key_press(GdkEventKey* event) { std::cout << event->keyval << "\n"; Gtk::CellRenderer* r=m_TreeView.get_column_cell_renderer (1); Gtk::CellRendererText* cr=dynamic_cast<Gtk::CellRendererText*>(r); std::cout << cr->gobj()->text << "\n"; } I only get the "old" value stored in the treeview. Not the one in the editable. -------- Original-Nachricht -------- > Datum: Mon, 9 Nov 2009 11:24:18 +0600 > Von: "Галымжан Кожаев" <kozhayev@...> > An: "José Alburquerque" <jaalburquerque@...> > CC: Thomas Sommer <mawa15@...>, gtkmm-list@... > Betreff: Re: treeview Tab control > Hi, Thomas! > You wrote that hitting Tab erases cell, restoring it to value stored > in TreeStore. What if you will somehow get the text in edited column > and manually set the value in TreeStore using that key_pressed > handler? I think text is getting lost because treeview displays data > in model (in our case treestore), am I right ? > > 2009/11/5, José Alburquerque <jaalburquerque@...>: > > On Wed, 2009-11-04 at 22:03 +0100, Thomas Sommer wrote: > >> Hi Jose, > >> > >> you will find the hacked treeview from the gtkmm examples in the > >> attachment. > >> > >> Basically all I did was attaching on_key_press() to signal_key_pressed. > >> Funny thing tough: If I add the column > >> > >> m_TreeView.get_columns(); > >> > >> to the attached function, everything works as I would expect it. > >> It just does not seem to make any sense to me. > > > > It doesn't make sense to me either. What I would suggest is that you > > guide yourself from the example that you hacked. On this system the > > example works fine (with tabs, etc.) as you also want. I can't tell > > definitely but, once more, my guess would be that if you handle key > > presses, I don't think that you need to pay special attention to the tab > > key. This is just a guess as I'm going by how the original example > > works on this system. > > > > -- > > José > > > > _______________________________________________ > > gtkmm-list mailing list > > gtkmm-list@... > > http://mail.gnome.org/mailman/listinfo/gtkmm-list > > -- Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 - sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
| Free embeddable forum powered by Nabble | Forum Help |