Tree selecting with SelObserver, can't clear selection

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
freedman
Veteran
Posts: 3465
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Tree selecting with SelObserver, can't clear selection

Post by freedman »

I run this code, pretty standard stuff. If I click on a sketch name in the tree I get my printed message but if I then click on the same sketch name again I get no printed message, I would like a response regardless if I clicked on the named sketch at some earlier state. Is there some way to clear the memory of a earlier event which stored the name.
My goal is to run something any time something in the treeview is clicked on, if you have any other approaches i'm open.
Thanks

Code: Select all

import math,FreeCAD
from FreeCAD import Base

class SelObserver:

    def setSelection(self,document):                     # Selection in ComboView
        App.Console.PrintMessage(" Clicked on")

s=SelObserver()
FreeCADGui.Selection.addObserver(s)          # install the function mode resident
Post Reply