How to get a string using InputDialog with FxRuby

Hi all,

Does anyone know how to get user input using InputDialog with FxRuby?

Thanks,

Li

On Sep 25, 2:25 pm, Li Chen [email protected] wrote:

Hi all,

Does anyone know how to get user input using InputDialog with FxRuby?

Thanks,

Li

Posted viahttp://www.ruby-forum.com/.

The docs (http://www.fxruby.org/doc/api/classes/Fox/
FXInputDialog.html) are very clear, IMHO

Need more details or a code sample?

Cheers
Chris

Chris H. wrote:

On Sep 25, 2:25?pm, Li Chen [email protected] wrote:

Hi all,

Does anyone know how to get user input using InputDialog ?with FxRuby?

Thanks,

Li

Posted viahttp://www.ruby-forum.com/.

The docs (http://www.fxruby.org/doc/api/classes/Fox/
FXInputDialog.html) are very clear, IMHO

Need more details or a code sample?

Cheers
Chris

I need a code sample.

Thanks,

Li

Hi Chris,

Here is the script:

require ‘fox16’
include Fox

result = FXInputDialog.getString(“Enter some text…”,self,“New
InputDialog”,“Please type some text:”)
if result
print "User entered: " + result
end

Here is the result of running the script:

C:\ruby\self\fox>fox1.rb
C:/ruby/self/fox/fox1.rb:4:in `getString’: No matching function for
overloaded ‘FXInputDialog_getString’ (ArgumentError)
from C:/ruby/self/fox/fox1.rb:4

I am sure what is wrong?

Li

On Sep 26, 8:38 am, Li Chen [email protected] wrote:

Posted viahttp://www.ruby-forum.com/.

Thanks,

Li

Posted viahttp://www.ruby-forum.com/.

I was hopping you’d provide a sample of code showing what you are
trying to do :wink:

a very simple example:

result = FXInputDialog.getString(“Enter some text…”,self,“New
InputDialog”,“Please type some text:”)
if result
print "User entered: " + result

cheers

On Sep 26, 12:20 pm, Li Chen [email protected] wrote:

if result


Posted viahttp://www.ruby-forum.com/.

Sorry about that, I was on a computer without Ruby so it only worked
in Theory :wink:

Here is a full working example:
require ‘rubygems’
require ‘fox16’
include Fox

if FILE == $0
FXApp.new do |app|
app.create
result = FXInputDialog.getString(“Enter some text…”,app,“New
InputDialog”,“Please type some text:”)
if result
puts "User entered: " + result
else
puts “User cancled!”
end
end
end

The dialog requires an app (or a parent window), my initial example
didn’t account for that

Any clearer?

Here is a full working example:
require ‘rubygems’
require ‘fox16’
include Fox

if FILE == $0
FXApp.new do |app|
app.create
result = FXInputDialog.getString(“Enter some text…”,app,“New
InputDialog”,“Please type some text:”)
if result
puts "User entered: " + result
else
puts “User cancled!”
end
end
end

Now the code is working. I have one more question. I copy one method
from FxRuby’s rdoc as follows:

getString(initial, app, caption, label, ic=nil)
Prompt for a string, in a free-floating window…

What does ic=nil mean?

Thanks,

Li

Li Chen wrote:

Hi Chris,

Here is the script:

require ‘fox16’
include Fox

result = FXInputDialog.getString(“Enter some text…”,self,“New
InputDialog”,“Please type some text:”)
if result
print "User entered: " + result
end

Here is the result of running the script:

C:\ruby\self\fox>fox1.rb
C:/ruby/self/fox/fox1.rb:4:in `getString’: No matching function for
overloaded ‘FXInputDialog_getString’ (ArgumentError)
from C:/ruby/self/fox/fox1.rb:4

I am sure what is wrong?

Li

Sorry there is a typo in my earlier post: I am NOT sure what is wrong
about the results when I followed Chris’s code sample.

Thanks,

Li

Hi Chris,

Thank you very much. Now I think it is a little bit easier for me to
read the FxRuby API document.

Li

On Sep 28, 9:10 am, Li Chen [email protected] wrote:

if result

getString(initial, app, caption, label, ic=nil)
Prompt for a string, in a free-floating window…

What does ic=nil mean?

Thanks,

Li


Posted viahttp://www.ruby-forum.com/.

Don’t see anything in the FXRuby docs, but according to the Fox docs
for FXInputDialog that parameter is an FXIcon. So I guess you can
pass a reference to an Icon to be displayed in the dialog

Cheers