André, as localDispatch is yours, perhaps you can help me with this problem. 
It's come up because I'm starting to deal with insets which have a dialog 
but which are also editable.

Inset::localDispatch is called from LyXFunc::dispatch (below). If this fails 
then the LFUN is passed to BufferView::dispatch which contains a switch for 
the different LFUNs.

                        ...
                        } else if (((result=inset->
                                     // Hand-over to inset's own dispatch:
                                     localDispatch(FuncRequest(view(), action, 
argument))) ==
                                    DISPATCHED) ||
                                   (result == DISPATCHED_NOUPDATE))
                                goto exit_with_message;
                                        // If UNDISPATCHED, just soldier on

The insets have a localDispatch method that is now handles LFUN_INSET_APPLY. 
My problem lies with the 'inset' in the above block of code. For example, I 
have two ERT insets. Right click one to pop up the dialog. Move the cursor 
into the other and now press 'Apply'. The changes in the dialog should 
apply to the first, 'opened' inset that is stored in a map in the Dialogs 
class. The code above causes it to be applied to the second inset that 
contains the cursor.

The 'fix' is simple:
                        } else if (action != LFUN_INSET_APPLY &&
                                   ((result=inset->
                                     // Hand-over to inset's own dispatch:
                                     localDispatch(FuncRequest(view(), action, 
argument))) ==
                                    DISPATCHED) ||
                                   (result == DISPATCHED_NOUPDATE))
                                goto exit_with_message;
                                        // If UNDISPATCHED, just soldier on

Meaning that the code in BufferView_pimpl.C's dispatch is called to do the 
right thing. But is there a better way?

-- 
Angus

Reply via email to