Home /Modules/gui/SLGuiEventType.sleela

SLGuiEventType.sleela

lib/gui/version-thual/SLGuiEventType.sleela · 121 line(s) · sleela

<< lib/gui/version-thual/SLGuiEventType.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLGuiEventType — the catalogue of GUI event kinds the
     /lib/gui event layer understands. These are the SLeeLa-facing names a
     handler binds to (the DHTML-style "click", "input", "change", "keydown",
     ...). The host raises one of these on a target; SLeeLa decides what it
     means. Each kind has a stable ordinal (used by the dispatch tables) and a
     canonical lowercase name (the string an onX binding or addEventListener
     uses), mirroring the activation model already in SLGuiAction.
   
   Family: gui. Java/native raise typed activations; SLeeLa owns their meaning. >>
#sleela 2.5
material;
class SLGuiEventType {
  < ---- 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 = 11212;
  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; }
  < Ordinals (stable; used as table indices). >
  < a primary activation (click / Enter / Space) >
  static final int CLICK      = 0;
  < a double activation >
  static final int DBLCLICK   = 1;
  < live text input (per keystroke) >
  static final int INPUT      = 2;
  < a committed value change (blur/Enter) >
  static final int CHANGE     = 3;
  < the target gained focus >
  static final int FOCUS      = 4;
  < the target lost focus >
  static final int BLUR       = 5;
  < a key went down while focused >
  static final int KEYDOWN    = 6;
  < a key came up while focused >
  static final int KEYUP      = 7;
  < a pointer press began on the target >
  static final int POINTERDOWN= 8;
  < a pointer press ended on the target >
  static final int POINTERUP  = 9;
  < the pointer moved over the target >
  static final int POINTERMOVE=10;
  < the target scrolled >
  static final int SCROLL     =11;
  < a form-like submit (Enter in an entry) >
  static final int SUBMIT     =12;
  < a toggle/checkbox flipped >
  static final int TOGGLE     =13;
  < a host- or script-defined event >
  static final int CUSTOM     =14;

  < number of defined event kinds >
  static final int COUNT      =15;

  < The canonical lowercase name for an ordinal (the addEventListener string). >
  String nameOf(int type) {
    if (type == CLICK)       { return "click"; }
    if (type == DBLCLICK)    { return "dblclick"; }
    if (type == INPUT)       { return "input"; }
    if (type == CHANGE)      { return "change"; }
    if (type == FOCUS)       { return "focus"; }
    if (type == BLUR)        { return "blur"; }
    if (type == KEYDOWN)     { return "keydown"; }
    if (type == KEYUP)       { return "keyup"; }
    if (type == POINTERDOWN) { return "pointerdown"; }
    if (type == POINTERUP)   { return "pointerup"; }
    if (type == POINTERMOVE) { return "pointermove"; }
    if (type == SCROLL)      { return "scroll"; }
    if (type == SUBMIT)      { return "submit"; }
    if (type == TOGGLE)      { return "toggle"; }
    if (type == CUSTOM)      { return "custom"; }
    return "unknown";
  }

  < The ordinal for a canonical name (-1 when the name is not recognised). >
  int typeOf(String name) {
    for (int t = 0; t < COUNT; t = t + 1) {
      if (nameOf(t) == name) { return t; }
    }
    return -1;
  }

  boolean valid(int type) { return type >= 0 && type < COUNT; }
}