Nifty Window onStartScreenEffect triggered on drag

Hi,



while digging into nifty gui i have come to a problem which i do not understand.



I create a window element with onStartScreenEffect (move in from top border).

Window works and i can drag it around, but every time i start dragging, the onStartScreenEffect ist triggered.



After setting some breakpoints i found out that the start effect is triggered from somewhere in the DraggableControl, here the stack trace:

Thread [LWJGL Renderer Thread] (Suspended (breakpoint at line 261 in EffectProcessor))

EffectProcessor.startEffect(Effect, String, String) line: 261

EffectProcessor.activate(EndNotify, String, String) line: 153

EffectManager.startEffect(EffectEventId, Element, TimeProvider, EndNotify, String) line: 87

Element.startEffectInternal(EffectEventId, EndNotify, String) line: 1040

Element.startEffectDoIt(EffectEventId, EndNotify, String, boolean) line: 1000

Element.startEffect(EffectEventId, EndNotify, String) line: 950

Element.startEffect(EffectEventId, EndNotify) line: 946

Screen.addPopup(Element, Element) line: 164

Nifty.showPopup(Screen, String, Element) line: 782

DraggableControl$1.perform() line: 146

Nifty$EndOfFrameElementAction.perform() line: 1004

Nifty.executeEndOfFrameElementActions() line: 376

Nifty.handleDynamicElements() line: 295

Nifty.access$1400(Nifty) line: 72

Nifty$NiftyInputConsumerImpl.processEvent(NiftyMouseInputEvent) line: 1345

Nifty$NiftyInputConsumerImpl.processMouseEvent(int, int, int, int, boolean) line: 1311

InputSystemJme.onMouseButtonEventQueued(MouseButtonEvent, NiftyInputConsumer) line: 128

InputSystemJme.forwardEvents(NiftyInputConsumer) line: 171

Nifty.update() line: 227

InputSystemJme.endInput() line: 94

InputManager.processQueue() line: 773

InputManager.update(float) line: 837

ModelViewer(Application).update() line: 567

ModelViewer.update() line: 316

LwjglDisplay(LwjglAbstractDisplay).runLoop() line: 144

LwjglDisplay.runLoop() line: 185

LwjglDisplay(LwjglAbstractDisplay).run() line: 218

Thread.run() line: 679



Here the code i use to build the window:

[java]

WindowBuilder window_builder = new WindowBuilder(NiftyConstants.SETTINGS_ID, NiftyConstants.SETTINGS_ID)

{

{

width("320");

height("200");

alignCenter();

valignCenter();



onStartScreenEffect(new EffectBuilder("move")

{

{

length(150);

inherit();

neverStopRendering(true);

effectParameter("mode", "in");

effectParameter("direction", "top");

}

});

onEndScreenEffect(new EffectBuilder("move")

{

{

length(150);

inherit();

neverStopRendering(true);

effectParameter("mode", "out");

effectParameter("direction", "bottom");

}

});

}

};

[/java]





Should there not be any effect on a window element, or what am i doing wrong here?

uhm, I think that this is a “odd” feature :slight_smile:



internally the window control (or any draggable) is using niftys popup mechanism. when a popup is being shown the onStartScreen effect will be triggered automatically.



what you can do - as a workaround - is to use a custom effect instead of the onStartScreen effect and trigger that one from code.

aah ok, that explains. already found out it has something to do with the popup mechanism, but was not sure.

Thank you for your answer.



But how should i implement the custom effect to be triggered on start/end?

Are custom effects in general explained somewhere?

And will this not be triggered by popup too?



Sorry for these questions, but i am pretty new to nifty and just getting started.

Ok, first the general explanation of custom effects:



Instead of writting: “onStartScreenEffect” you can use “onCustomEffect”. This will not start the effect automatically because you can decide when the effect should start. When you want to activate the effect you get the Element with the attached effect first, something like:



[java]Element e = screen.findElementByName(")[/java]



and then use:



[java]e.startEffect(EffectEventId.onCustom);[/java]



to start the custom effect.



You should be able to add this at the time where you show/build the actual window.