View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Fri Apr 15, 2016 3:34 am Post subject: Is this a Lua bug or not? createOpenDialog |
|
|
Please take a look at the screenshot. I am trying to make save and load functions for the settings of my trainer.
When I clicked the "red cross" or "cancel" to close the dialog window, the file (123.txt) was still loaded if I had selected it with my mouse (but I did not click "open" yet). Shouldn't the program just simply close the dialog window without loading the file? Because I did not click "open".
Is there a way to fix it? Thanks.
My code is something like this, I am planning to use it to load the settings of the trainer. Sorry for the awful variable name:
Code: |
function CEButton2Click(sender)
dialog2 = createOpenDialog(sender)
dialog2.DefaultExt=".txt"
dialog2.Filter="TXT File (*.txt)|*.txt"
dialog2.FilterIndex=1
dialog2.execute()
local f = io.open(dialog2.Filename,"r")
if f == nil then
return 0
else
local t = f:read("*a")
f:close()
local tt = t:match("checkbox1")
local ttt = tonumber(string.sub(t,#tt+3,#tt+3))
if ttt == 1 then
CETrainer.CECheckbox1.checked = true
end
tt = t:find("editbox1")
ttt = string.sub(t,tt+10,tt+15)
if ttt ~= 0 then
control_setCaption(CETrainer.CEEdit1,ttt)
end
.......
......
end
|
Description: |
|
Filesize: |
111.74 KB |
Viewed: |
3205 Time(s) |
|
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Apr 15, 2016 4:52 am Post subject: |
|
|
From main.lua
Code: | CommonDialog class:
properties
OnShow: function(sender)
OnClose: function(sender)
Title: string - The caption at top of the dialog
methods
Execute() : Shows the dialog and return true/false depending on the dialog |
So:
Code: | if dialog2.execute()
// stuff here
end |
_________________
|
|
Back to top |
|
|
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Fri Apr 15, 2016 10:41 am Post subject: |
|
|
mgr.inz.Player wrote: | From main.lua
Code: | CommonDialog class:
properties
OnShow: function(sender)
OnClose: function(sender)
Title: string - The caption at top of the dialog
methods
Execute() : Shows the dialog and return true/false depending on the dialog |
So:
Code: | if dialog2.execute()
// stuff here
end |
|
Thanks a lot, mgr.inz.Player.
|
|
Back to top |
|
|
|