How to get a string using InputDialog with FxRuby

L

Li Chen

Hi all,

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

Thanks,

Li
 
C

Chris Hulan

I need a code sample.

Thanks,

Li

I was hopping you'd provide a sample of code showing what you are
trying to do ;)

a very simple example:
<code>
result = FXInputDialog.getString("Enter some text...",self,"New
InputDialog","Please type some text:")
if result
print "User entered: " + result
</code>

cheers
 
L

Li Chen

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
 
L

Li Chen

Li said:
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
 
C

Chris Hulan

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

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

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?
 
L

Li Chen

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
 
C

Chris Hulan

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

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
 
L

Li Chen

Hi Chris,

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

Li
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top