Home /Modules/gui/SLGuiEvent.sleela

SLGuiEvent.sleela

lib/gui/version-mual/SLGuiEvent.sleela · 107 line(s) · sleela

<< lib/gui/version-mual/SLGuiEvent.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLGuiEvent โ€” one dispatched GUI event, the DHTML-style
     event object a handler receives. It names the event type (an SLGuiEventType
     ordinal), the target node id it was raised on, and the payload the kind
     carries: a string value (entry text / changed value), a key name (for
     key events), pointer coordinates (for pointer events), and a toggle state.
     It also carries the two propagation controls a handler can set โ€”
     preventDefault() and stopPropagation() โ€” exactly like a browser event, so
     SLeeLa handlers can cancel the host's default action or halt bubbling.
   
   Family: gui. The host raises the activation; SLeeLa reads this event and
   decides what it means. >>
#sleela 2.5
material;
class SLGuiEvent {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 11201;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-16";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }
  < SLGuiEventType ordinal >
  int type;
  < the node id the event was raised on >
  String targetId;
  < string payload (entry text, changed value, custom data) >
  String value;
  < key name for KEYDOWN/KEYUP (e.g. "Enter", "a") >
  String key;
  < pointer x within the target (pointer events) >
  int x;
  < pointer y within the target (pointer events) >
  int y;
  < 1/0 for TOGGLE events >
  int toggleState;
  < 1 once preventDefault() is called >
  int defaultPrevented;
  < 1 once stopPropagation() is called >
  int propagationStopped;
  < host-supplied monotonic tick (0 if unknown) >
  int timestamp;

  void configure(int eventType, String target) {
    type = eventType; targetId = target;
    value = ""; key = ""; x = 0; y = 0; toggleState = 0;
    defaultPrevented = 0; propagationStopped = 0; timestamp = 0;
  }

  int getType() { return type; }
  String target() { return targetId; }

  < Payload setters (the host fills in what the kind carries). >
  void setValue(String v) { value = v; }
  String getValue() { return value; }
  void setKey(String k) { key = k; }
  String getKey() { return key; }
  void setPointer(int px, int py) { x = px; y = py; }
  int pointerX() { return x; }
  int pointerY() { return y; }
  void setToggle(int on) { toggleState = on; }
  boolean toggledOn() { return toggleState == 1; }
  void setTimestamp(int t) { timestamp = t; }
  int when() { return timestamp; }

  < DHTML-style propagation controls. >
  void preventDefault() { defaultPrevented = 1; }
  boolean isDefaultPrevented() { return defaultPrevented == 1; }
  void stopPropagation() { propagationStopped = 1; }
  boolean isPropagationStopped() { return propagationStopped == 1; }
}