Initialization : I had a complete Scene.addChild(WidgetP)
and WidgetP.addChild(WidgetC)
structure, and added a defaultMoveAction
to WidgetP
. I override the isHitAt
method of WidgetP
such that it will return true if any of its children.isHitAt
returns true.
Problem : I tried to drag WidgetP
, but it won’t move. Hmm there must be something wrong with my code, so I switch back to Netbeans but it seems that there’s nothing wrong. So I switch back to my app and WidgetC
has been moved. Ghost. I move it again, it stands still. I zoom the Scene
out, it moves.
I tried to listen the event and put a SceneListener on my TopComponent. Indeed, no event is fired while I drag the widget.
The thing is, if I drag WidgetC
far enough to trigger the scrollbar to appear, it is rendered correctly under my cursor.
Culprit : WidgetP extends LayerWidget
.
Solution : Changing the declaration of superclass from LayerWidget
to Widget
solves the problem.
Lesson learned : LayerWidget.isRepaintRequiredForRevalidating
always returns false. Next time, I will remind myself not to type extends LayerWidget
and use Widget
instead.