Giter Club home page Giter Club logo

Comments (6)

enebo avatar enebo commented on July 24, 2024

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

from jrubyfx.

retorquere avatar retorquere commented on July 24, 2024

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?

from jrubyfx.

retorquere avatar retorquere commented on July 24, 2024

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?

from jrubyfx.

enebo avatar enebo commented on July 24, 2024

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...

from jrubyfx.

enebo avatar enebo commented on July 24, 2024

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.

from jrubyfx.

retorquere avatar retorquere commented on July 24, 2024

Splendid! Still requires master, right? No probs, loving this!

from jrubyfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.