Permalink
Browse files

Simple patch that will make sure that selections can only be made by …

…clicking and dragging within the text.

The old behavior allowed residual dragging from other widgets to start selecting the text in the text field. Also caused by a small issue where the release methods are not fired when the mouse is released over another window or alert. This is mitigated by basically augmenting the logic of the mouse[0] field with another instance variable that denotes a click has been made within the widget.

Some cleanup of hard tabs to spaces was done in other parts by coincidence. Discipline!

Closes #41
  • Loading branch information...
1 parent 2797e46 commit d6dc85d49a4aa81ca0ab2455e516321f6ca197f1 @wilkie wilkie committed Dec 19, 2010
Showing with 10 additions and 6 deletions.
  1. +10 −6 app/ui/editor/editor.rb
View
@@ -187,7 +187,7 @@ def @t.hit_sloppy(x, y)
if self.cursor == :arrow
self.cursor = :text
end
- if self.mouse[0] == 1
+ if self.mouse[0] == 1 and @clicked
if @t.marker.nil?
@t.marker = c
else
@@ -198,9 +198,13 @@ def @t.hit_sloppy(x, y)
self.cursor = :arrow
end
end
+ release do
+ @clicked = false
+ end
click do |_, x, y|
c = @t.hit_sloppy(x, y)
if c
+ @clicked = true
@t.marker = nil
@t.cursor = c
end
@@ -226,12 +230,12 @@ def @t.hit_sloppy(x, y)
end
end
end
- @save_to_cloud_button =
+ @save_to_cloud_button =
glossb "Upload", :width => 70, :top => 2, :left => 0 do
- hacker = Hacker.new :username => HH::PREFS['username'], :password => HH::PREFS['password']
- hacker.save_program_to_the_cloud script[:name].to_slug, @str
- alert("Uploaded!")
- end
+ hacker = Hacker.new :username => HH::PREFS['username'], :password => HH::PREFS['password']
+ hacker.save_program_to_the_cloud script[:name].to_slug, @str
+ alert("Uploaded!")
+ end
glossb "Run", :width => 52, :top => 2, :left => 130 do
eval(@str, HH.anonymous_binding)
end

0 comments on commit d6dc85d

Please sign in to comment.