Martin Vermeer wrote:

> On Wed, Nov 12, 2003 at 08:29:12AM +0000, Angus Leeming spake
> thusly:
>> 
>> [EMAIL PROTECTED] wrote:
>> > Looks like just the other way around, in fact:
>> 
>> Sigh. I need a holiday to recover from the holiday.
>> Ah well,
>> --
>> Angus
> 
> Angus,
> 
> sorry to disturb your ongoing holiday :-) but what's wrong with this
> code (attached)? When I try to insert a label, it correctly creates
> a little grey inset button and pops up the dialog, but when I enter
> something and press "Apply" (or OK), out comes

In itself, that looks wrong. The button should not be created at 
all until "Apply" has been pressed.

You should be invoking the Dialogs::show member function to
pop up the dialog. If you press the button to launch the dialog,
then an InsetLabel pointer is passed to the function. On return
from the dialog ("Apply") the global dispatch() interrogates the
Dialogs class: "has any particular inset got an open dialog?" 

Here are the two functions:

class Dialogs {
pulic:
        /** \param name == "bibtex", "citation" etc; an identifier used to
            launch a particular dialog.
            \param data is a string representation of the Inset contents.
            It is often little more than the output from Inset::write.
            It is passed to, and parsed by, the frontend dialog.
            \param inset is _not_ passed to the frontend dialog.
            It is stored internally and used by the kernel to ascertain
            what to do with the FuncRequest dispatched from the frontend
            dialog on 'Apply'; should it be used to create a new inset at
            the current cursor position or modify an existing, 'open' inset?
        */
        void show(std::string const & name, std::string const & data, 
                          InsetBase * inset);
        ///
        InsetBase * getOpenInset(std::string const & name) const;

};

> LyXFunc::dispatch: cmd:  action: 236 arg: 'label LatexCommand
> \label{abc}
> \end_inset
> ' x: 0 y: 0
> 
> LCursor::dispatch:
> 
> trying to dispatch to main text 0x08b00ce8
> LyXText::dispatch: cmd:  action: 236 arg: 'label LatexCommand
> \label{abc}
> \end_inset
> ' x: 0 y: 0
> INSET APPLY name:label
> APPLY: no inset

So, presumably this means that Dialogs::getOpenInset is returning 0?

> It's the "APPLY: no inset" message I don't understand. There IS an
> inset and it should be found, shouldn't it?

Only if Dialogs::show is being passed an inset in the first place.
In your case, I think tht you shouldn't be creating the inset before
calling Dialogs::show...


-- 
Angus

Reply via email to