Class: VR::Alert

Inherits:
Object
  • Object
show all
Includes:
GladeGUI
Defined in:
lib/Alert.rb

Overview

Class that the #alert method uses. This class is note useful by itself. See #alert method instead.

See Also:

  • #alert

Defined Under Namespace

Classes: DialogAnswer

Instance Attribute Summary collapse

Attributes included from GladeGUI

#builder

Instance Method Summary collapse

Methods included from GladeGUI

#buttonCancel__clicked, #extract_key, #fill_control, #get_control_value, #get_glade_active_record, #get_glade_all, #get_glade_variables, included, #load_glade, #parse_signals, #set_drag_drop, #set_glade_active_record, #set_glade_all, #set_glade_hash, #set_glade_variables, #show_glade, #try_to_select_text_in_combobox, #window1__destroy, #window1__key_press_event

Constructor Details

#initialize(message, answer, flags = {}) ⇒ Alert

Just passes on values from #alert method.

See Also:

  • #alert


16
17
18
19
20
21
22
# File 'lib/Alert.rb', line 16

def initialize(message, answer, flags = {})
  @flags = flags
  @answer = answer
  @message = message
  @p = nil

end

Instance Attribute Details

#answerObject

Returns the value of attribute answer.



8
9
10
# File 'lib/Alert.rb', line 8

def answer
  @answer
end

Instance Method Details

#before_showObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/Alert.rb', line 24

def before_show
  @flags[:title] = @flags[:title] ? @flags[:title] : @flags[:headline]
  @builder[:window1].title = @flags[:title] if @flags[:title]
  @builder[:window1].resize(@flags[:width],100) if @flags[:width].to_i > 100
  @builder[:headline].show if @flags[:headline]

  if @flags[:input_text]
    @flags[:button_yes] ||= "Save"
    @flags[:button_no] ||= "Cancel"
    @builder[:input_text].show
  elsif choices = @flags[:choices]
    @flags[:button_yes] ||= "Select"
    @flags[:button_no] ||= "Cancel"
    choices.each { |c| @builder[:choices_text].append_text(c) }
    @choices_text = choices[0]
    @builder[:choices_text].show 
  end 

  @builder[:button_no].show if @flags[:button_no]
  @builder[:button_cancel].show if @flags[:button_cancel]
  set_glade_hash(@flags)
end

#button_cancel__clicked(but) ⇒ Object

answer stays nil



63
64
65
# File 'lib/Alert.rb', line 63

def button_cancel__clicked(but) #answer stays nil  
  @builder[:window1].destroy
end

#button_no__clicked(but) ⇒ Object



58
59
60
61
# File 'lib/Alert.rb', line 58

def button_no__clicked(but)
  @answer.answer = false    
  @builder[:window1].destroy
end

#button_yes__clicked(but) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/Alert.rb', line 47

def button_yes__clicked(but)
  if @flags[:input_text]
    @answer.answer = @builder[:input_text].text 
  elsif @flags[:choices]
    @answer.answer = @builder[:choices_text].active_text
  else
    @answer.answer = true
  end
  @builder[:window1].destroy
end