-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag & Drop treeview #17
Comments
I would try something like this: class MyTreeCell < TreeCell
def updateItem(item, empty)
super(item, empty)
text = item unless item
end
end
#...in scenebuilding part of your code.
tree_view do
set_cell_factory do
MyTreeCell.new.tap do |tree_cell|
tree_cell.set_on_drag_detected do |mouse_event|
# ...
end
end
end
end |
I've tried this (https://gist.github.com/4678888), but that makes the textx not render, and I see no sign of dnd. I've found a more compicated (but more complete) sample of tree drag and drop in java. I'll see if I can make that work; do you want a pull request for a working sample if I do? |
I've tried to translate https://gist.github.com/4009620 to jrubyfx, but I keep tripping up on the event handler stuff. Any general pointers on how to approach this? |
I made a couple of tweaks to get (https://gist.github.com/4678888) working. I am unclear why MyTreeCell's super does not render the contents directly. It still seems like you want the method for updateItem I provided though (reversed unless to if and did self.text so we used text= method and not local variable text). You will also notice I changed how tree_view and tree_item setup. This only works on master. After you reported this issue I decided to play with tree_view + tree_items and made some changes to have them behave more like the rest of the DSL. FWIW, I don't know if set_on_drag_detected is all you need to do or not but I can see that method firing when I try to drag something. It just doesn't actually show any graphics of something being dragged... |
Look at this sample: https://github.com/nahi/jrubyfx/blob/master/samples/javafx/tree_view.rb It basically implements reasonable drag and drop support. The code you had used was partially dependent on other classes in a framework. This code is not quite the same since I changed some behavior and I think fixed several corner cases. This was surprisingly tedious but I wanted to include a more sophisticated example. I am resolving this issue because this example should show more than enough examples of how to work with Java classes and define event handlers. |
Splendid! Still requires master, right? No probs, loving this! |
Can someone help me to get this: http://stackoverflow.com/questions/11242847/is-drag-and-drop-supported-by-treeitem implemented using jrubyFX? I've got the tree working, which was simple, but the drag and drop bits use a callback mechanism which I'm not sure how to translate into jrubyfx.
The text was updated successfully, but these errors were encountered: