On 06/06/2010 12:50 PM, Rob Oakes wrote:
Dear LyX-Developers,
After spending some time this morning looking at various LFUNs that are used to
insert different types of insets (e.g., LFUN_NOTE_INSERT, etc.), I had a
question about what the best way to programmatically create an inset with text
is.
Here is what I would like to accomplish:
From within one of the two custom views I'm creating (expanded outline
pane/corkboard), I'd like for a user to create a new section, or new summary
note. In the view, a new object will appear that prompts for text. Then, once
the text has been entered and the display destroyed, a method will then locate
the appropriate place in the document and add the correct type of inset with
text.
In the example of the note inset, I thought it might be possible to chain
several together several existing LFUNs, specifically LFUN_NOTE_INSERT and
LFUN_SELF_INSERT. I haven't yet worked out what the best way to do this with
headings is yet.
So, I suppose here is my question: Is this the best way to do this, or am I
missing something? Is there another LFUN that can be used to add an inset
(with text) to a particular location in a document?
What if the user wants to enter math in the note or heading?
Given that question, what I'd suggest is that you not worry about the
text part. Just insert the note or section heading, perhaps with dummy
text, and switch focus there so the user can type what he or she wants.
If you had dummy text, you could probably even highlight it so that
starting to type would delete it.
If chaining existing LFUNs is too complicated, you can always just
invent your own.
Richard