From d51710eb3e5e4161d406bc2179b1c3cb21c04f36 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 29 Aug 2001 11:01:05 +0000 Subject: [PATCH] Add a pre-handler that triggers an input event when text is pasted into 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 | 8 ++++++++ src/frontends/xforms/FormBase.C | 20 ++++++++++++++++++++ src/frontends/xforms/FormPreamble.C | 8 +++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 6a5e1f9800..25069f11fa 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2001-08-29 Angus Leeming + + * 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 * FormCitation.C: diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index 70038eb489..5b5b737643 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -21,8 +21,15 @@ #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(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; +} diff --git a/src/frontends/xforms/FormPreamble.C b/src/frontends/xforms/FormPreamble.C index eed32d8163..537ec7012e 100644 --- a/src/frontends/xforms/FormPreamble.C +++ b/src/frontends/xforms/FormPreamble.C @@ -18,6 +18,11 @@ #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 > 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);