RosettaCodeData/Task/GUI-component-interaction/Elena/gui-component-interaction.e...

58 lines
1.3 KiB
Plaintext

import forms;
import extensions;
public class MainWindow : SDIDialog
{
Button btmIncrement;
Button btmRandom;
Edit txtNumber;
constructor new()
<= super new()
{
btmIncrement := Button.new();
btmRandom := Button.new();
txtNumber := Edit.new();
self
.appendControl(btmIncrement)
.appendControl(btmRandom)
.appendControl(txtNumber);
self.Caption := "Rosseta Code";
self.setRegion(100, 100, 180, 140);
txtNumber.setRegion(20, 7, 140, 25);
txtNumber.Caption := "0";
btmIncrement.setRegion(20, 35, 140, 25);
btmIncrement.Caption := "Increment";
btmIncrement.onClick := (args){ self.onButtonIncrementClick() };
btmRandom.setRegion(20, 65, 140, 25);
btmRandom.Caption := "Random";
btmRandom.onClick := (args){ self.onButtonRandomClick() };
}
private onButtonIncrementClick()
{
var number := txtNumber.Value.toInt();
number := number + 1;
self.changeTextBoxValue(number)
}
private onButtonRandomClick()
{
if(messageDialog.showQuestion("Inf", "Really reset to random value?"))
{
self.changeTextBoxValue(randomGenerator.nextInt(99999999))
}
}
private changeTextBoxValue(number)
{
txtNumber.Caption := number.toString()
}
}