This I understand and it works correctly. Problem is when there are different objects. Because "mat" is always the last highlitged object, if more then one object was highlighted only last one will be unhighlighted. I changed "mat" to list and append all highlighted nodes to it. It seems working, but don't think it is correct solution because there are many duplicated inputs possible.It's not necessarily a bug. If the two lines are part of the same SoLineSet node then it's OK. And note, the script was only a quick hack to demonstrate how the mechanism is working.There is a little bug - if you have couple ovelapped objects and move cursor from one to enouther the way first one stays highlighted, that object will stay highlighted even when cursor moved away.
There is one more issue - when object changed color during mouse movements sometimes area under the previous cursor location getting wrong color patch. It means that mouse buffer has data from the screen before redraw. It is may be only Windows issue. May be you know how to fix it?
Andrey