Book a Demo

Author Topic: modifying selected text of Element.notes  (Read 4220 times)

Stanislav Hrabí

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
modifying selected text of Element.notes
« on: August 14, 2020, 05:55:31 pm »
Hello,

I was wondering - is it somehow possible to access (in a script) only a selected part of the Notes property?

The Element.Notes property only allows me to work with the text as a whole. I'd like to run a script which could modify the selected part of the notes property.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: modifying selected text of Element.notes
« Reply #1 on: August 14, 2020, 06:12:39 pm »
You need to use the GetFieldFromFormat and GetFormatFromField operations of the repository class. Awkwards as so many EA things.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: modifying selected text of Element.notes
« Reply #2 on: August 14, 2020, 06:20:30 pm »
I think the OP meant if you make a selection (highlight) of part of the text in a Notes field, can you access that selection through the API?

And the answer is no.

The operations Q refers to are needed to deal with formatting in Notes fields, but there is no support for text selection.


/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: modifying selected text of Element.notes
« Reply #3 on: August 14, 2020, 06:40:20 pm »
Ah, I see. Aren't there any Windoze backdoors?

q.

Stanislav Hrabí

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: modifying selected text of Element.notes
« Reply #4 on: August 14, 2020, 06:44:29 pm »
Thanks for the replies.

My mistake for not making it clearer in OP
- Uffe's interpretation is/was correct - thanks for a confirmation of what I was afraid of :-)

Although the Repository.GetFieldFromFormat and Repository.GetFormatFromField are indeed interesting functions, afaik they will not help me in the screnario

Let's say I've got element notes like this:
"Example element note" -i.e. the note with a part of it bold

If I then call something like: Session.Output(Repository.GetFieldFromFormat("html",selectedElement.Notes));
I'll get
Code: [Select]
Example [b]element [/b]note
This could allow me (in conjunction with GetFormatFromField) for example find all bold parts of a note and add a font color to them

But what I want to do is to select/highlight part of the text and run a script, which would add pair tags around the selection - e.g. let's say i select/highlight "Example", I'd run a script and it the output would be
Code: [Select]
Example [b]{startOfTxtInsertedByScript}element {/endOfTxtInsertedByScript} [/b]note

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: modifying selected text of Element.notes
« Reply #5 on: August 14, 2020, 06:48:09 pm »
You're free to send a feature request to Down Under. Just if you really believe in Santa, you know?

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: modifying selected text of Element.notes
« Reply #6 on: August 14, 2020, 07:43:48 pm »
Hi again,


But what I want to do is to select/highlight part of the text and run a script, which would add pair tags around the selection - e.g. let's say i select/highlight "Example", I'd run a script and it the output would be
Code: [Select]
Example [b]{startOfTxtInsertedByScript}element {/endOfTxtInsertedByScript} [/b]note

I see what you're after. It could be useful, but I don't think such a feature request would be implemented because it would break compatibility for a lot of scripts and add-ins already out there.

You might have more luck if you request it as a new add-in event, specifically a context item event. These deal with selections in the GUI (selecting an element in the browser or a diagram), and this could fit in alongside those. Something like

    EA_OnTextSelectionChanged(repository, guid, objectType, property, startPos, endPos)

where repository, guid and objectType are the same as in the three existing operations, startPos and endPos are integers specifying the selection in the string, and property is an enum specifying which property the selection is in (name, alias, notes, etc).

Now, adding another add-in event doesn't help you if you're just using the Object Model (scripting). But you can created scripted add-ins these days (as opposed to .NET DLL ones), so you could make that work.

So as an add-in event I think it's worth a feature request.


/Uffe
My theories are always correct, just apply them to the right reality.