Method: ActionBuilder#list
- Defined in:
- lib/qtext/action_builder.rb
#list(group_name) {|_self| ... } ⇒ Object
Create and return a list of actions. The actions are grouped together, but not as strongly as with Qt::ActionGroup. A method called “#group_name_actions” will be added to self, which will return the set of Qt::Action instances created in the block.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/qtext/action_builder.rb', line 109 def list( group_name, &block ) @group_name = group_name group_names << group_name unless respond_to?( "#{group_name.to_s}_actions" ) self.class.send( :define_method, "#{group_name.to_s}_actions" ) do eval "@#{group_name.to_s}_actions" end end self.collect_actions = [] yield( self ) # copy actions to the right instance variable eval "@#{group_name.to_s}_actions = collect_actions" # reset these, just for cleanliness @group_name = nil self.collect_actions = [] end |