Permalink
Browse files

make clicks work better

  • Loading branch information...
1 parent 0606b7e commit b07b0916908ce4f41f40b6298c4864a8df04b2ce @rdp committed Oct 11, 2012
Showing with 27 additions and 12 deletions.
  1. +3 −1 TODO
  2. +1 −2 lib/simple_gui_creator/parse_template.rb
  3. +12 −3 lib/simple_gui_creator/swing_helpers.rb
  4. +11 −6 spec/parse_template.spec.rb
View
4 TODO
@@ -1,6 +1,8 @@
see spec/parse_template.spec.rb for another (the real) TODO list
-revamp GUI (add drop down, better demo template), re-release, release on ruby flow LOL.
+revamp bin/GUI (add drop down, better demo template), re-release, release on ruby flow LOL.
+
+better docu (basically, everything you need, in the README)
= maybe =
@@ -85,7 +85,6 @@ def parse_setup_string string
size_x = @window_max_x + 25
size_y = @current_y + 40 # 40, but why when the init was 10? huh?
@frame.set_size size_x, size_y
- puts 'set size after line', line, idx, size_x, size_y
rescue
puts "Parsing failed on line #{line.inspect} number: #{idx+1}!"
raise
@@ -215,7 +214,7 @@ def setup_element element, name_and_code, height=nil, set_text_on_this = element
end
if !width
if text.blank?
- raise 'cannot have blank original text without width specifier:' + name
+ raise 'found an element without any text, and without a width specifier:' + name + ' ' + name_and_code
end
if text.strip != text
# let blank space count as "space" for now, but don't actually set it LOL
@@ -235,20 +235,29 @@ def go_selected_value
class JCheckBox
def after_checked &block
- add_action_listener {
+ add_item_listener {
if isSelected # they just 'added' a check mark
block.call
end
}
end
- def after_unchecked &block
- add_action_listener {
+ def after_unchecked &block
+ add_item_listener {
if !isSelected # they just "unchecked" it
block.call
end
}
end
+
+ def click!
+ doClick()
+ end
+
+ def set_checked!
+ setSelected(true)
end
+
+ end
end
@@ -167,7 +167,7 @@ def get_dimentia(element)
frame = parse_string string
frame.elements[:text_area].class.should == Java::JavaxSwing::JTextArea
frame.elements.length.should == 1 # not create fake empty buttons underneath :)
- text_area_dimentia(frame.elements[:text_area]).should == [0, 0, 32, 319] # it's "sub-contained" in a jscrollpane so these numbers are relative to that <sigh>
+ text_area_dimentia(frame.elements[:text_area]).should == [0, 0, 48, 319] # it's "sub-contained" in a jscrollpane so these numbers are relative to that <sigh>
end
def text_area_dimentia(element)
@@ -212,12 +212,17 @@ def text_area_dimentia(element)
end
it "should allow for checkboxes" do
- for string in ["[✓:checkbox_name]", "[✓ : checkbox_name]", "[_:checkbox_name"] # UTF-8 <sigh>
+ # fails 1.9 ...
+ for string in ["[✓:checkbox_name]", "[✓ : checkbox_name]"] # UTF-8 <sigh> possibly someday: "[_:checkbox_name]"
f = parse_string string
- f.elements[:checkbox_name].get_text.should == ""
- f.elements[:checkbox_name].class.should == Java::JavaxSwing::JCheckBox
- f.elements[:checkbox_name].after_checked { puts 'checked!' }
- f.elements[:checkbox_name].after_unchecked { puts 'unchecked!' }
+ checkbox = f.elements[:checkbox_name]
+ checkbox.class.should == Java::JavaxSwing::JCheckBox
+ checkbox.get_text.should == ""
+ got_check = false
+ checkbox.after_checked { got_check = true }
+ checkbox.set_checked!
+ assert got_check
+ #checkbox.after_unchecked { puts 'unchecked!' } # untested...
f.close
end
end

0 comments on commit b07b091

Please sign in to comment.