Ide Scripting: SelectProjectItem

I am attempting to use:

Dim didSelect As Boolean didSelect = SelectProjectItem("MyClass.Constructor")

But didSelect is turning out to be False, even though MyClass.Constructor exists. I can do:

Location = "MyClass.Constructor"

and the method is activated, but it leaves the text cursor in the “Method Name” text field of the Inspector. If the inspector is hidden, it will make it visible, and select it.

My desired outcome would be to select the method leaving the cursor in the code editor. Is there a way to accomplish this?

MyClass.Constructor is not a project item
MyClass is

So, there is no way to select a given method and have the cursor appear in the editor?

What would you do at that point ?
Since you cant say “move up, move left etc” what does having the cursor IN the editor matter ?
I’d have a peek at SelText, SelStart, SelLength & Text

You can say move up, move down, left, right. Using a SelStart = PositionOffset, and SelLength = 0, you have complete cursor control, which is what I wish to do, move to a given line/column, which I can already do, once the editor is active.

BTW, setting SelStart, SelLength does not bring focus to the editor.

I was playing with my parser that I use in my Format Code script with a real Xojo app. I made an application that you can drag your .xojo_project to and it will parse the code, presenting a list of Todo items, priorities and location. It will refresh the data when brought active, parsing only those items that have changed. You can sort by priority, location or todo type (TODO, BUG, FEATURE). When double clicking on an item, it communicates with Xojo via the REALStudioIDE socket asking it to go to a given location, currently I set Location = blah, blah blah and then I wanted to move to the line/column of the todo entry comment.

That, however, is just one thing I wish to do with this functionality. I do a lot of scripting to automate various things.

Not sure how you plan to say “go to line 64”

But no - its never been required to make the editor & insertion point active to manipulate that text using IDE script so it doesn’t work that way.

Going to line 64 is easy, just parse .Text and find the offset of where line 64 is. With the editor active, I can make the cursor go to any row,col position I wish. This parsing happens very quickly in scripting, but for this app, I am storing the offset and project item in my SourceTodo class. Then, when double clicked in the program, it simply executes:

Location = "blahblah.blah" SelStart=position

OK then I guess all I can say is “Yeah it doesn’t work like that”.
You’d need to put in an FR to do what you want.

Thanks!

<https://xojo.com/issue/28476>.

For this sort of thing I just put a note
// TODO
with appropriate comments right inline in the code

A search finds them all very quickly and others on our team can get them when they update from SVN so if I dont deal with it someone else can

That’s what this program does, it scans your code for // TODO, // BUG, // FEATURE and presents them in a listbox showing in a tool window. Double clicking the item will take you to the point in your code where they are defined. The program doesn’t create any todo type data itself, it’s all source comments, or items in notes formated as [ ] Blah blah. You can also assign a priority, // TODO P2: Blah, blah, blah. Thus, everything is in your source, shared with others, etc… Sometimes, but rarely, we use hash tags as well, such as // TODO P3: Do something here #jeremy so others in my team know that I want to handle this issue.

One can sort by priority and immediately get a list sorted by priority of todo items as defined by notes or source comments in the project, and the items are shared of course via git/svn when you commit/push your code.

This Todo list program, however, is just one example of why the ability to activate an editor is a handy thing to do.