On Friday 02 August 2002 12:03 pm, Andre Poenitz wrote:
> On Fri, Aug 02, 2002 at 11:10:14AM +0100, Angus Leeming wrote:
> > Yes, I've looked at the code in editing().
> >
> > > On second thoughts, maybe the math cursor does not get destroyed if the
> > > inset is left...
> >
> > that would indeed bugger it up ;-)
> >
> > > Is there some equivalent to the edit() that gets called when an inset
> > > is left?
> >
> > You've lost me. What are you talking about?
>
> I was asking whether there is some function in th LyX insets that gets
> calleds when ever the LyX inset is losing focus (i.e. some equivalent to
> math inset's 'notifyCursorLeave'). In this case we could just destroy the
> math cursor there.
I don't think so, but we can use notifyCursorLeaves().
At the momenet I call generatePreview from notifyCursorLeave only if a
mathcursor exists and in generatePreview do nothing if !previewWanted().
Which in this case is
bool InsetFormula::PreviewImpl::previewWanted() const
{
return !parent().par_->asNestInset()->editing();
}
A lovely example of Angus going round in circles.
The fix is to have a bool inInset flag in InsetFormulaBase that is set to
true in edit() and is set to false in a new method leaving() invoked from
notifyCursorLeaves().
void MathNestInset::notifyCursorLeaves()
{
// Generate a preview only if we are leaving the InsetFormula itself
if (!mathcursor || mathcursor->depth() != 1)
return;
InsetFormulaBase * inset = mathcursor->formula();
- inset->generatePreview();
+ inset->leaving();
}
leaving() would also invoke generatePreview().
This would mean that you could throw away NestInset()->editing() because the
InsetFormula would already know this.
What do you think?
Angus