Здесь я сгруппировал кнопки.Интересно,есть ли ошибки в данном коде?))
counter = 0
GraphicsWindow.Width = 500
GraphicsWindow.Height = 300
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Простейший текстовый редактор"
GraphicsWindow.BrushColor = "Blue"
Button_1 = Controls.AddButton("Открыть файл", 0,0)
Controls.SetSize(Button_1, 300,50)
Button_2 = Controls.AddButton("сохранить файл",0,0)
Controls.SetSize(Button_2, 300,50)
Controls.HideControl(Button_2)
Button_3 = Controls.AddButton(">>>",250,0)
Controls.SetSize(Button_3, 300,50)
Controls.ButtonClicked = OnButtonClick
Controls.TextTyped = OnTextTyped
NewEdit_1 = Controls.AddMultiLineTextBox(0,50)
Controls.SetSize(NewEdit_1, 500,250)
NewEdit_2 = Controls.AddTextBox(0,200)
Controls.SetSize(NewEdit_2, 500,25)
Controls.SetTextBoxText(NewEdit_2,"filename.txt")
resulttext = ""
filename = "filename.txt"
Sub OnButtonClick
if Controls.LastClickedButton = Button_1 Then
result = File.ReadContents(filename)
Controls.SetTextBoxText(NewEdit_1,result)
EndIf
if Controls.LastClickedButton = Button_2 Then
File.WriteContents(filename,resulttext)
EndIf
if Controls.LastClickedButton = Button_3 And counter = 1 Then
counter = counter + 1
Controls.HideControl(Button_2)
Controls.ShowControl(Button_1)
endif
if Controls.LastClickedButton = Button_3 And counter = 0 Then
counter = counter + 1
Controls.HideControl(Button_1)
Controls.ShowControl(Button_2)
endif
If counter = 2 Then
counter = 0
endif
EndSub
Sub OnTextTyped
edit = Controls.LastTypedTextBox
If edit = NewEdit_1 then
resulttext = Controls.GetTextBoxText(edit)
EndIf
If edit = NewEdit_2 then
filename = Controls.GetTextBoxText(edit)
EndIf
EndSub
|