Sublime Forum

Attach view event to specific view

#1

I’m trying to set event listener to specific view ?

something like this

view = self.window.new_file()
view.settings().set('color_scheme' , "...")
view.on_selection_modified( callback )

I have tried the following but it listen all view events but I need only one

class OnLoadedViewCommand( sublime_plugin.ViewEventListener ):

  def on_selection_modified( self, view ):
           print(  "I am Test1."  )

Is it posible ?

1 Like

#2

How do you know which particular view you want to listen for?

0 Likes

#3

Is not directly possible to only call the method on a specific view, but it is possible to ignore all other views. E.g.

view = self.window.new_file()
view.settings().set('color_scheme' , "...")
view.settings().set('execute_my_callback' , True)

and then

    def on_selection_modified( self, view ):
        if not view.settings().get('execute_my_callback'):
            return
        print(  "I am Test1."  )
2 Likes

#5

Thank you for your help

0 Likes

#6

Is it with python
And HTML

0 Likes