If for the window set the parameter “hidden = false”, the event “onShow” will not be called when the window starts first time.
But if you hide the window and show it again, the event will be triggered.
Hello,
Window view is created hidden, so to make it visible you need to use show() method
Please check the sample: https://snippet.webix.com/vlsc3odo
Thanks for the answer, but the documentation has a special setting. And the event system is not working as expected.
https://docs.webix.com/api__link__ui.window_hidden_config.html
In addition, when creating a window, the onHide event is called.
Hello @lBeJIuk ,
Each window state (hidden/shown) triggers the corresponding callback including the related events. While the window is created, the initial state is applied to it with the same common logic - it is intended behaviour.
If you need to attach events handlers which will not be triggered during the init, please set them in $ready array - all methods from there will be executed after the component is initialized.
Please, check the following example: https://snippet.webix.com/15s61zhd
Hello @Listopad
Thanks for the answer!
And what about the flag “hidden”?
@Listopad
I just can not understand why when initializing the window causes the event “onHide”. Although trying to hide a window that is already hidden, this event does not work.
In other “onShow” behaves differently …
https://snippet.webix.com/eef2df90
@lBeJIuk could you please clarify the desired behaviour?
The sequence of the related methods is the following:
- setting handlers from $init,
- initial state setter (hidden_setter in the source code).
At this point, only event handlers attached in $init will be executed, - setting handlers from on,
- setting handlers from $ready.
The hidden_setter will always trigger the event corresponding to the applied state (similar to hide/show methods), but due to the sequence described above, only a handler from $init can be executed for it during the initialization.
just can not understand why when initializing the window causes the event “onHide”. Although trying to hide a window that is already hidden, this event does not work.
I understand the confusion.
Only changes of visibility will trigger the corresponding events.
During the init, the state of visibility (hidden:true
or false
- the default value) will be assigned to a window.
It can be considered as a change from nothing to a boolean value.
Afterwards, the visibility can be changed manually with hide/show
methods.
If you apply hide
to an actually hidden window, it will not trigger any changes neither visually nor in the inner logic, e.g. no event will be called.
A bit different situation with show method - please, check its API.
While hide
simply changes the visibility, show
is responsible for calculating the position of a window and its rendering (quick example).
So when this method is called, it recalculates window position, e.g. shows it on some coordinates (either taken from config or passed to a method).
In order to prevent re-showing the window, you can check the visibility before applying show
:
if ( w.config.hidden ){ // or if ( !w.isVisible() )
w.show();
}
Ok! Many thanks for the explanation