summaryrefslogtreecommitdiff
path: root/gtk2_ardour/floating_text_entry.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-11-02 08:54:51 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-11-02 08:58:07 -0500
commitf76109d8734983e696959df7e7dc62722d621ccf (patch)
tree8f8db2c6ca081675a3e8dc4dc63848bc0ad9f90a /gtk2_ardour/floating_text_entry.cc
parente4e6f001036102aab8bee42516335ea236aa9644 (diff)
use modal grab and event_is_inside_widget_window() to provide "expected" behaviour when editing in a FloatingTextEntry
Diffstat (limited to 'gtk2_ardour/floating_text_entry.cc')
-rw-r--r--gtk2_ardour/floating_text_entry.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/gtk2_ardour/floating_text_entry.cc b/gtk2_ardour/floating_text_entry.cc
index 21be620ddb..0df7221c84 100644
--- a/gtk2_ardour/floating_text_entry.cc
+++ b/gtk2_ardour/floating_text_entry.cc
@@ -17,30 +17,61 @@
*/
+#include "pbd/stacktrace.h"
+
#include "floating_text_entry.h"
#include "gtkmm2ext/doi.h"
+#include "gtkmm2ext/utils.h"
#include "i18n.h"
FloatingTextEntry::FloatingTextEntry ()
: ArdourWindow ("")
+ , entry_changed (false)
{
set_name (X_("FloatingTextEntry"));
set_position (Gtk::WIN_POS_MOUSE);
set_border_width (0);
entry.show ();
+ entry.signal_changed().connect (sigc::mem_fun (*this, &FloatingTextEntry::changed));
entry.signal_activate().connect (sigc::mem_fun (*this, &FloatingTextEntry::activated));
entry.signal_key_press_event().connect (sigc::mem_fun (*this, &FloatingTextEntry::key_press));
+ entry.signal_button_press_event().connect (sigc::mem_fun (*this, &FloatingTextEntry::button_press));
add (entry);
}
void
+FloatingTextEntry::changed ()
+{
+ entry_changed = true;
+}
+
+void
FloatingTextEntry::on_realize ()
{
ArdourWindow::on_realize ();
get_window()->set_decorations (Gdk::WMDecoration (0));
+ entry.add_modal_grab ();
+}
+
+bool
+FloatingTextEntry::button_press (GdkEventButton* ev)
+{
+ if (Gtkmm2ext::event_inside_widget_window (*this, (GdkEvent*) ev)) {
+ return true;
+ }
+
+ /* Clicked outside widget window - edit is done */
+
+ if (entry_changed) {
+ use_text (entry.get_text ());
+ }
+
+ delete_when_idle ( this);
+
+ return false;
}
void
@@ -67,6 +98,8 @@ FloatingTextEntry::key_press (GdkEventKey* ev)
void
FloatingTextEntry::on_hide ()
{
+ entry.remove_modal_grab ();
+
/* No hide button is shown (no decoration on the window),
so being hidden is equivalent to the Escape key or any other
method of cancelling the edit.