GUI component interaction: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Changed to Wren S/H) |
imported>Arakov |
||
Line 896: | Line 896: | ||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA |
ELENA 6.x : |
||
<syntaxhighlight lang="elena">import forms; |
<syntaxhighlight lang="elena">import forms; |
||
import extensions; |
import extensions; |
||
Line 914: | Line 914: | ||
self |
self |
||
.appendControl |
.appendControl(btmIncrement) |
||
.appendControl |
.appendControl(btmRandom) |
||
.appendControl |
.appendControl(txtNumber); |
||
self.Caption := "Rosseta Code"; |
self.Caption := "Rosseta Code"; |
||
Line 953: | Line 953: | ||
txtNumber.Caption := number.toString() |
txtNumber.Caption := number.toString() |
||
} |
} |
||
}</syntaxhighlight> |
|||
=== Alternative version using xforms script === |
|||
form layout: |
|||
<syntaxhighlight lang="elena"><Form X="100" Y="100" Width="160" Height="120" Caption="Rosseta Code"> |
|||
<Edit ID="txtNumber" X="7" Y="7" Width="140" Height="25" Caption="0"> |
|||
</Edit> |
|||
<Button ID="btmIncrement" X="7" Y="35" Width="140" Height="25" Caption="Increment" onClick="onButtonIncrementClick"> |
|||
</Button> |
|||
<Button ID="btmRandom" X="7" Y="65" Width="140" Height="25" Caption="Random" onClick="onButtonRandomClick"> |
|||
</Button> |
|||
</Form></syntaxhighlight> |
|||
main code: |
|||
<syntaxhighlight lang="elena">import xforms; |
|||
import forms; |
|||
import extensions; |
|||
public class MainWindow |
|||
{ |
|||
SDIForm form; |
|||
Button btmIncrement; |
|||
Button btmRandom; |
|||
Edit txtNumber; |
|||
constructor new() |
|||
{ |
|||
form := xforms.executePath("main.xs", self); |
|||
btmIncrement := form.Controls.btmIncrement; |
|||
btmRandom := form.Controls.btmRandom; |
|||
txtNumber := form.Controls.txtNumber; |
|||
} |
|||
onButtonIncrementClick(sender) |
|||
{ |
|||
var number := txtNumber.Value.toInt(); |
|||
number := number + 1; |
|||
self.changeTextBoxValue(number) |
|||
} |
|||
onButtonRandomClick(sender) |
|||
{ |
|||
if(messageDialog.showQuestion("Inf", "Really reset to random value?")) |
|||
{ |
|||
self.changeTextBoxValue(randomGenerator.eval(99999999)) |
|||
} |
|||
} |
|||
private changeTextBoxValue(number) |
|||
{ |
|||
txtNumber.Caption := number.toString() |
|||
} |
|||
dispatch() => form; |
|||
}</syntaxhighlight> |
}</syntaxhighlight> |
||