Open passenger94 opened 9 years ago
I started working on this with a test script
Shoes.app do
@el = edit_line
button "insert this" do
@el.text = 'insert this'
end
para "Watch the cursor"
end
but the doesn't show a problem (gtk or cocoa). @passenger94 I need more complete description of how to use this new method so I can write a bug test.
Shoes.app title: "to_end test", height: 150 do
@history, @pointer = [], 0
keypress do |k|
case k
when :up
@entry.text = @history[@pointer]
#@entry.to_end
@pointer -= 1 unless @pointer == 0
when :down
@pointer += 1 unless @pointer == @history.size-1
@entry.text = @history[@pointer]
@entry.to_end
end
end
para "Enter words in Edit_Line below to fill the history stack\nTry KeyUp/KeyDown and Watch cursor ..."
@entry = edit_line "", width: 0.9, margin: [10,10,0,10]
@entry.finish = proc { |e| @history << e.text
@pointer = @history.size-1
e.text = ""
}
timer(0) { @entry.focus }
end
That's a simplified version of where i found the need for the method, probably an edge case ...
Thank you. Now I can see what needs to be done. On OSX (w/o a fix) the words from the history show up in the edit_line as selected/hightlighted if the edit_line does not have focus which it won't because Shoes OSX don't do focus well. If the edit_line does have focus then the edit_line swallows the up/down and doesn't pass them to Shoes (known behavior) Since I've spent the last week getting educated about osx text handling I think it might be fixable. It is an edge case but it does exist.
It looks like this is going to be a LARGE amount of work to implement on OSX since it involves the control focus handling (really) and that's iffy in gtk and it's worse on OSX. The app @passenger94 got the test snippet from is never going to be a happy Shoes/OSX app (for reasons mentioned above and #36).
I'm going to put this in the low priority queue until someone really wants to dig into all the focus issues with OSX. The to_end method exists in Gtk and harmless in OSX and is undocumented. I think it should stay undocumented.
when programmatically pasting text in an edit_line, cursor stays at the beginning of the text, this methods sends it at the end (implemented in gtk.c as "shoes_native_edit_line_cursor_to_end" ) #126 needs the same in cocoa