Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

add PopupMenu.scala #11

Open
wants to merge 1 commit into from

3 participants

@sullivan-

Hi Ingo! Here's a wrapper for JPopupMenu. I hope you can use it! Best, John

@ingoem
Owner
@sullivan-
@sullivan-

Hi Ingo,

It's been about 3 weeks since I put the CLA in the mail. Do you know if it has arrived yet?

Best, John

@ingoem
Owner
@sullivan-
@digicyc

Is there any update on this patch by chance? Would really like to use this natively in Scala.

@ingoem
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 27, 2011
  1. @sullivan-

    add PopupMenu.scala

    sullivan- authored
This page is out of date. Refresh to see the latest.
Showing with 51 additions and 0 deletions.
  1. +51 −0 src/main/scala/scala/swing/PopupMenu.scala
View
51 src/main/scala/scala/swing/PopupMenu.scala
@@ -0,0 +1,51 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2007-2010, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+
+
+package scala.swing
+
+import javax.swing.JPopupMenu
+
+object PopupMenu {
+ private[PopupMenu] trait JPopupMenuMixin { def popupMenuWrapper: PopupMenu }
+}
+
+/**
+ * A popup menu.
+ *
+ * Example usage:
+ *
+ * {{{
+ * val popupMenu = new PopupMenu {
+ * contents += new Menu("menu 1") {
+ * contents += new RadioMenuItem("radio 1.1")
+ * contents += new RadioMenuItem("radio 1.2")
+ * }
+ * contents += new Menu("menu 2") {
+ * contents += new RadioMenuItem("radio 2.1")
+ * contents += new RadioMenuItem("radio 2.2")
+ * }
+ * }
+ * val button = new Button("Show Popup Menu")
+ * reactions += {
+ * case e: ButtonClicked => popupMenu.show(button, 0, button.bounds.height)
+ * }
+ * listenTo(button)
+ * }}}
+ *
+ * @see javax.swing.JPopupMenu
+ */
+class PopupMenu extends Component with SequentialContainer.Wrapper {
+
+ override lazy val peer: JPopupMenu = new JPopupMenu with PopupMenu.JPopupMenuMixin with SuperMixin {
+ def popupMenuWrapper = PopupMenu.this
+ }
+
+ def show(invoker: Component, x: Int, y: Int): Unit = peer.show(invoker.peer, x, y)
+}
Something went wrong with that request. Please try again.