Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How can I get a return value from a dialog window ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Feb 23, 2025 6:25 am    Post subject: How can I get a return value from a dialog window ? Reply with quote

Hi,
Is it possible to get a return value from a dialog window ?
Trying to get a return result for (open/save/OK) or (cancel/close).

Code:
myForm = createForm()
myForm.setSize(300,300)

local memo = createMemo(myForm)
memo.setSize(myForm.Width,myForm.Height - 100)

local button = createButton(myForm)
button.setSize(myForm.Width,100)
button.Top = 200
button.Caption = 'Open'

button.OnClick=function(sender)
  local OpenDialog = createOpenDialog(myForm)
  OpenDialog.execute()
  -------------------------------------------------------
  --print(OpenDialog.GetDialogResult) -- or maybe
  --if (whatever is clicked on) then
    --return ???
  -------------------------------------------------------
  --else
    -- do stuff
    memo.Lines.Insert(1,'Line 1')
    memo.Lines.add('Last line')
  --end
end

openfile()
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 468

Joined: 09 May 2003
Posts: 25707
Location: The netherlands

PostPosted: Sun Feb 23, 2025 7:48 am    Post subject: Reply with quote

OpenDialog.execute() returns true when a file has been selected and not canceled
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Feb 23, 2025 8:29 am    Post subject: Reply with quote

OK Thanks Dark Byte.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1481

PostPosted: Sun Feb 23, 2025 12:52 pm    Post subject: Reply with quote

Code:
button1.OnClick=function(sender)
  local OpenDialog = createOpenDialog(myForm)
  --OpenDialog.execute()
  -------------------------------------------------------
  if OpenDialog.execute() then --if file name then (open-save-ok-true)
     memo1.Lines.add(OpenDialog.FileName)
  else -- (cancel-close-false)
    memo1.Lines.add('Cancel')
  end
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites