-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panorama Template & Event System #25
base: old-wiki
Are you sure you want to change the base?
Panorama Template & Event System #25
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep panel events out of this, since they aren't really referenced anywhere else here and might just be confusing