class Iup::FileDialog

A FileDialog is a predefined dialog for selecting files or a directory. The dialog can only be shown using the popup function.

Attributes

allownew

If set, indicates if non-existent filenames are accepted. Values as 'yes' / 'no' - defaults to 'no'.

dialogtype

'open' / 'save' / 'dir'

directory

Initial directory

extfilter

Defines filters, e.g. “Text files|.txt;.doc|Image files|.gif;.jpg;*.bmp|”, has priority over filterinfo and filter.

file

Name of file. Will be used instead of dictionary if it contains a complete path.

filter

Filter to use, e.g. “.C;.LED;test.*”.

filterinfo

Information about the filter, e.g. “C files”.

filterused

n, index of filter from extfilter that was used. Index counts from 1.

multiplefiles

'no' / 'yes', set to allow selection of multiple files.

nochangedir

'yes' / 'no', if set, restores current directory after dialog is closed.

nooverwriteprompt

'no' / 'yes', if set, prompts before overwriting existing files.

parentdialog

This dialog will be always in front of the parent dialog. If the parent is minimized, this dialog is automatically minimized. Important Closing the parent will also close the child, but the child dialog's CLOSE_CB method will not be called.

showhidden

'no' / 'yes', if set, shows hidden files.

showpreview

'no' / 'yes', if set, shows a preview area for file.

status

read-only Returns an integer: 1 for new file, 0 for existing file/directory, for -1 for cancelled.

title

Title text for the file dialog.

value

read-only Name of file(s) selected.

Public Class Methods

new(&block) click to toggle source

Creates a dialog, using the optional block to set its attributes.

# File lib/wrapped/filedialog.rb, line 36
def initialize &block
  @handle = IupLib.IupFileDlg

  self.instance_eval &block if block_given?
end

Public Instance Methods

file_cb(callback) click to toggle source

Called when a file is selected.

callback

takes two arguments, a filename and a status.

# File lib/wrapped/filedialog.rb, line 80
def file_cb callback
  unless callback.arity == 2
    raise ArgumentError, 'file_cb callback must take 2 arguments, a filename, and status'
  end
  cb = Proc.new do |ih, fn_ptr, st_ptr|
    fn = FFI::Pointer.new(fn_ptr).read_string
    st = FFI::Pointer.new(st_ptr).read_string
    callback.call fn, st
  end
  define_callback cb, 'FILE_CB', :ss_i
end
popup(x=0, y=0) click to toggle source

Shows the dialog at position x, y.