Skip to content
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

Convenience methods for clipboard assignment don't work #190

Closed
benedictleejh opened this issue Apr 27, 2015 · 4 comments
Closed

Convenience methods for clipboard assignment don't work #190

benedictleejh opened this issue Apr 27, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@benedictleejh
Copy link

@benedictleejh benedictleejh commented Apr 27, 2015

When attempting to assign to the clipboard, using the convenience methods result in a compile error. The test code is included below.

object Test {
  val clipboard = new Clipboard(Clipboard.systemClipboard)

  val cnt = new ClipboardContent()
  cnt.putString("Hello")

  clipboard.content = cnt //compile error: Reassignment to val
}

I'm on ScalaFX 8.0.40-R8, Scala 2.11.6, and JDK 8u45

@jpsacha
Copy link
Member

@jpsacha jpsacha commented Apr 27, 2015

JavaFX getContent(...) takes a parameter. Scala content_=(...) requires parameter-less content.

The only fix I see is to use getContent(...)/setContent(...), adding wrapper that use ScalaFX types. So it would be:

  val cnt = new ClipboardContent()
  cnt.putString("Hello")
  clipboard.setContent(cnt)

Any suggestions on better way of doing this?

@benedictleejh
Copy link
Author

@benedictleejh benedictleejh commented Apr 27, 2015

While it would break the parallel with JavaFX, a possibility would be for content to return the entire Map (possibly as ClipboardContent), while having a get(...) to get individual key-value pairs. get would thus ideally also return an Option instead of null where no such element exists. This would allow keeping the convenience method.

@jpsacha
Copy link
Member

@jpsacha jpsacha commented Apr 29, 2015

Would you like to implement it and submit pull request (on master branch)?

@benedictleejh
Copy link
Author

@benedictleejh benedictleejh commented Apr 29, 2015

Alright, I'll give it a go. I'll see if I can't get something out over the weekend.

benedictleejh added a commit to benedictleejh/scalafx that referenced this issue May 1, 2015
… work

Because convenience methods such as `content_=` require a method without
the `_=` as part of the name, I've modified content to return all the
data on clipboard as `ClipboardContent`.

The individual `getContent` method from JavaFX has been renamed to get,
and optionally returns an object for the given data format, instead of
returning null, in order to be null-safe.
benedictleejh added a commit to benedictleejh/scalafx that referenced this issue May 2, 2015
The tests are designed as compile tests, i.e. if the tests compile, they
have passed. Ideally, since they technically don't do anything, they
should pass during runtime too, but they currently fail during runtime.
@jpsacha jpsacha added the bug label Sep 26, 2015
@jpsacha jpsacha added this to the 8.0.*-R9 milestone Sep 26, 2015
@jpsacha jpsacha self-assigned this Sep 28, 2015
jpsacha added a commit that referenced this issue Sep 28, 2015
Correct Clipboard assignment issues and remove deprecated MapProxy.
@jpsacha jpsacha closed this Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants