Sublime Forum

Edit a view without triggering on_modified

#1

Suppose I want to react to input in on_modified EventListener when a user writes something to a view. But I will also be inserting characters to the same view programmatically, and I want to ignore these in on_modified.
Somehow I would like to be able to take over control of the view and disable the on_modified listener, and subsequently give back release that control. Is this possible?

A flawed idea for a solution would be to set a flag in the view’s settings when I edit it programmatically and check for this in on_modified. However, I suspect this might not be bullet proof, as the user input and the programmatic input might get interleaved. Or am I wrong about this?

Thanks.

0 Likes

#2

You always will trigger on_modified.
The flag idea works in practice; I (and others, I believe) have used it successfully in plugins. Check out e.g. github.com/SublimeText/ElasticTabstops.

0 Likes

#3

Ok, that is it then. Thank you for the feedback.

0 Likes