Panorama Template & Event System#25
Panorama Template & Event System#25LauraWebdev wants to merge 6 commits intoStrataSource:old-wikifrom
Conversation
LauraWebdev
commented
Jan 31, 2023
- General changes for project setup
- Dev setup instructions in README
- Reorganized "Control: Label" page to a "Controls" subpage of Panorama
- Added initial documentation for the Event System
|
|
||
| ## Defining Events | ||
| ``` | ||
| **TODO** What is the difference between these two functions |
There was a problem hiding this comment.
Never actually used $.DefinePanelEvent but panel events are things like onmouseover, onactivate etc... No idea why you'd want define custom ones from JS tbh.
Worth distinguishing the two though. Regular events are basically like you say below. Panel events are subscribed to using panel.SetPanelEvent(event name, callback)
| Any panel can subscribe to an event by calling ``$.RegisterForUnhandledEvent`` or ``$.RegisterEventHandler`` within JavaScript. These functions will be called, when the event is fired. Some events may include additional parameters, which will be forwarded to your function. | ||
|
|
||
| #### $.RegisterForUnhandledEvent(``EVENT_NAME``, ``CALLBACK``) | ||
| This function can be used to subscribe to events. |
There was a problem hiding this comment.
Notably, this will only get fired if none of the handlers registered with "RegisterEventHandler" returned true (or i guess a truthy value in a JS setting)
|
|
||
| ### Example | ||
| ```js | ||
| $.DispatchEvent("LoadTutorialMap"); // Event "LoadTutorialMap" with no arguments |
There was a problem hiding this comment.
You can also pass as target panel as second parameter. Or if you use DispatchEventAsync, the second param is the delay, then optional target panel and then the rest
| ``` | ||
| **TODO** What is the difference between these two functions | ||
| ``` | ||
| You can define your own global events within the ``scripts/util/event-definition.js`` file by calling the ``$.DefineEvent`` and ``$.DefinePanelEvent`` functions. |
There was a problem hiding this comment.
I would keep panel events out of this, since they aren't really referenced anywhere else here and might just be confusing