]> git.lyx.org Git - features.git/commitdiff
Add a pre-handler that triggers an input event when text is pasted into
authorAngus Leeming <leeming@lyx.org>
Wed, 29 Aug 2001 11:01:05 +0000 (11:01 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 29 Aug 2001 11:01:05 +0000 (11:01 +0000)
an xforms text input widget.
Use this in the Preamble dialog.

If anybody wants to help add this functionality to the rest of the dialogs
then feel free. Apart from FormPreferences (which has it's own prehandler
already that would need to be modified) there are about 60 text input
widgets that all need the extra code:
extern "C" int C_CutandPastePH(FL_OBJECT *, int, FL_Coord, FL_Coord,
       int, void *);

fl_set_object_prehandler(widget, C_CutandPastePH);

Not too hard, is it?

Angus

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2613 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormPreamble.C

index 6a5e1f98004bb8ae2272e5a1c4d13108e78cb0b0..25069f11fa95832d0168c1219ff5115b4ea54383 100644 (file)
@@ -1,3 +1,11 @@
+2001-08-29  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormBase.C (C_CutandPastePH): new function that can be used as a
+       pre-handler to any xforms text input widget. Will trigger an event on
+       pasting into the widget using the middle mouse button.
+
+       * FormPreamble.C (build): use this pre-handler for the input widget.
+
 2001-08-26  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormCitation.C:
index 70038eb4892dd5ab9c555cc19c3d409ced5569b2..5b5b73764367e15a8396fff0e0ecce40a55ab719 100644 (file)
 #include "xformsBC.h"
 #include "support/LAssert.h"
 
+// Callback function invoked by xforms when the dialog is closed by the
+// window manager
 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
 
+// To trigger an input event when pasting in an xforms input object
+// using the middle mouse button.
+extern "C" int C_CutandPastePH(FL_OBJECT *, int, FL_Coord, FL_Coord,
+                              int, void *);
+
 
 FormBase::FormBase(ControlButtons & c, string const & t, bool allowResize)
        : ViewBC<xformsBC>(c), minw_(0), minh_(0), allow_resize_(allowResize),
@@ -155,3 +162,16 @@ extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
 {
        GetForm(ob)->InputCB(ob, d);
 }
+
+
+// To trigger an input event when pasting in an xforms input object
+// using the middle mouse button.
+extern "C" int C_CutandPastePH(FL_OBJECT * ob, int event,
+                              FL_Coord, FL_Coord, int key, void *)
+{
+       if ((event == FL_PUSH) && (key == 2) && (ob->objclass == FL_INPUT)) {
+               C_FormBaseInputCB(ob, 0);
+       }
+
+       return 0;
+}
index eed32d8163b276d9a68bce7aa084f4effa6bfddd..537ec7012e48fa2355407ec84f83d023ecdefba5 100644 (file)
 #include "form_preamble.h"
 #include "xforms_helpers.h"
 
+// To trigger an input event when pasting in an xforms input object
+// using the middle mouse button.
+extern "C" int C_CutandPastePH(FL_OBJECT *, int, FL_Coord, FL_Coord,
+                              int, void *);
+
 typedef FormCB<ControlPreamble, FormDB<FD_form_preamble> > base_class;
 
 FormPreamble::FormPreamble(ControlPreamble & c)
@@ -28,8 +33,9 @@ FormPreamble::FormPreamble(ControlPreamble & c)
 void FormPreamble::build()
 {
        dialog_.reset(build_preamble());
-   
+
        fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
+       fl_set_object_prehandler(dialog_->input_preamble, C_CutandPastePH);
 
        // Manage the ok, apply and cancel/close buttons
        bc().setOK(dialog_->button_ok);