Hi all,
I would like the entry widget respond when text is typed and enter key is pressed. I followed the documentation keyboard events programming with gtkmm 3 but could not resolve the issue. Any guidance would be really helpful
Thanks
Hi all,
I would like the entry widget respond when text is typed and enter key is pressed. I followed the documentation keyboard events programming with gtkmm 3 but could not resolve the issue. Any guidance would be really helpful
Thanks
So, show what you have triedā¦? Donāt make people guess, please.
You probably just need to connect a slot to signal_activate()
and have that slot do whatever you want to happen on Enter. Or did you already try that and it doesnāt work somehow?
Ok, I can get mouse clicked on widgets but not in entry widget. My plan is to first check if mouse has clicked on entry widget then check if there is a enter key hit afterwards then proceed. Maybe this is not the way to do it or maybe there is a much more simpler way to achieve this task, I have no idea.
this->signal_button_press_event().connect( sigc::mem_fun( *this, &ExampleWindow::onButtonPress), false)
bool onButtonPress(GdkEventButton* event){
std::cout<<āmouse clickedā<<std::endl;
so far I am here
Yes, the much simpler, better way to do it is by connecting to signal_activate()
, as I mentioned, which is specifically to tell you āthe user was in this entry and now they have pressed Enterā. You should not need to manually check whether they are there with the pointer, or manually check for specific key presses. So, have you tried signal_activate()
?
m_Entry->signal_activate().connect( sigc::mem_fun( *this, &ExampleWindow::onButtonPress), false)
returns error on compilation : error base operand of ā->ā has non-pointer type āGtk::Entryā
Others canāt read all your compiler error messages for you; at some point you have to think a little bit about them. That one is probably because you declare m_Entry
by value, not by pointer, but uncritically just substituted the this
pointer with m_Entry
without accommodating that the latter is not a pointer. If so, just use .
instead of ->
to match. So, use m_Entry.signal_activate().connect(whatever)
- and of course youāll need to ensure the connected function has the right arguments - in this case, none (void
), so you canāt just swap in your handler for button_press_event
without removing its arguments - and so on, stopping to think about any error you get along the way.
I canāt find signal_activate there is only activate() I am a little lost here. Can you provide an example on how to achieve this ?
You said you are using gtkmm
3, which does have Entry.signal_activate()
, as my link says, so if you are indeed using gtkmm
3 then I canāt see how it would not be available.
If you are using gtkmm
4, then I checked the gtkmm/entry.h
file for you quickly, and apparently that has indeed renamed it to .activate()
(it was removed and then re-added, and from reading the linked issues, Iām not sure the rename was 100% intentional, but here we are). So⦠just try it?
Beyond that, sorry, I donāt know of an example or have time to make one.
Ok, thank you for your effort, I figured it out!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.