/** * Build the script text for the Control * * @return string */ protected function buildScriptText() { $controlId = Builder::escapeText($this->control->getId()); $scriptText = ''; $closeBlock = false; if (ScriptLabel::isEventLabel($this->labelName)) { $scriptText .= "\nif (Event.ControlId == {$controlId}) {\ndeclare Control <=> Event.Control;"; $closeBlock = true; } else { $scriptText .= "\ndeclare Control <=> Page.GetFirstChild({$controlId});"; } $class = $this->control->getManiaScriptClass(); $name = preg_replace('/^CMl/', '', $class, 1); $scriptText .= "\ndeclare {$name} <=> (Control as {$class});\n"; $scriptText .= $this->scriptText . "\n"; if ($closeBlock) { $scriptText .= "}"; } return $scriptText; }
public function testEventLabels() { $this->assertCount(5, ScriptLabel::getEventLabels()); $this->assertTrue(ScriptLabel::isEventLabel(ScriptLabel::MOUSECLICK)); $this->assertFalse(ScriptLabel::isEventLabel(ScriptLabel::ONINIT)); }