Home Download Buy Blog Forum Support

Edit a view without triggering on_modified

Edit a view without triggering on_modified

Postby andershqst on Thu Sep 12, 2013 1:42 pm

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.
andershqst
 
Posts: 6
Joined: Fri Apr 26, 2013 10:35 am

Re: Edit a view without triggering on_modified

Postby adzenith on Thu Sep 12, 2013 3:44 pm

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. https://github.com/SublimeText/ElasticTabstops.
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: Edit a view without triggering on_modified

Postby andershqst on Thu Sep 12, 2013 6:08 pm

Ok, that is it then. Thank you for the feedback.
andershqst
 
Posts: 6
Joined: Fri Apr 26, 2013 10:35 am


Return to Plugin Development

Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests