Class: Nobbie::Wx::Command::ComponentAwareCommand
- Inherits:
-
Object
- Object
- Nobbie::Wx::Command::ComponentAwareCommand
show all
- Defined in:
- lib/nobbie/wx/command.rb
Overview
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ComponentAwareCommand.
6
7
8
|
# File 'lib/nobbie/wx/command.rb', line 6
def initialize(path)
@path = path
end
|
Instance Method Details
#component ⇒ Object
10
11
12
|
# File 'lib/nobbie/wx/command.rb', line 10
def component
@component ||= @path.find_component
end
|
#ensure_enabled(id = nil) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/nobbie/wx/command.rb', line 24
def ensure_enabled(id = nil)
enabled = id.nil? ? component.is_enabled : component.is_enabled(id)
Kernel.raise(ComponentDisabledException,
"cannot: #{describe} because component is disabled") unless enabled
end
|
#handle_unsupported_operation_for_component ⇒ Object
#handle_value_not_found ⇒ Object
19
20
21
22
|
# File 'lib/nobbie/wx/command.rb', line 19
def handle_value_not_found
Kernel.raise(ValueNotFoundException,
"cannot: #{describe} because value #{@value} not found")
end
|
#highlight(component = component) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/nobbie/wx/command.rb', line 32
def highlight(component = component)
Kernel.raise "highlight requires a block" unless block_given?
begin
unless [Menu, Panel].include?(component.class)
original_colour = component.background_colour
component.background_colour = Colour.from_hex('#FFFF00')
component.update
end
result = yield component
unless component.is_a?(Menu)
component.update
end
return result
ensure
unless [Menu, Panel].include?(component.class)
component.background_colour = original_colour
component.refresh
end
end
end
|