0

I'm writing a MEL script which involves opening the grease pencil UI toolbar. I want to remove the close button on that toolbar. I tried doing

GreasePencilTool;
window -edit -tbm 0 greasePencilFloatingWindow;

but get Error: line 2: window: Object 'greasePencilFloatingWindow' not found.

Further tests reveal that running

GreasePencilTool;
window -q -exists greasePencilFloatingWindow;

will return a result of 0.

Running GreasePencilTool; and then window -edit -tbm 0 greasePencilFloatingWindow; at separate times works as expected, as does running window -edit -tbm 0 greasePencilFloatingWindow; when the toolbar is already open.

However, I need to be able to remove the close button immediately when the toolbar opens.

The closest thing I can think of that illustrates what I want to do are Javascript callback functions, where another function can be executed once the current function is finished... but is there a way to do something like that in MEL?

I've also tried using the evalDeferred command without success.

dashik
  • 67
  • 1
  • 1
  • 6

1 Answers1

0

The grease pencil tool is launched asynchronously so the window will not be present for some unknown length of time. This means the best you could do is trigger a function which would check periodically and do it the next time you find the correctly named window; you could attach this to an idle time script job.

It's ugly. But it is probably the only way since there's no event that will notify when thje window arrives. If you do that, make the script job suicide after it fires so it's not sitting there on every idle check till the end of time.

theodox
  • 12,028
  • 3
  • 23
  • 36