Skip to content

Conversation

LauraWebdev
Copy link
Member

  • 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
Copy link
Member

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.
Copy link
Member

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
Copy link
Member

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.
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants