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
This commit is contained in:
Angus Leeming 2001-08-29 11:01:05 +00:00
parent 621c062434
commit d51710eb3e
3 changed files with 35 additions and 1 deletions

View 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:

View File

@ -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<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;
}

View File

@ -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<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);