Keyboard macros: Difference between revisions
Content added Content deleted
(→{{header|Java}}: Added a line so that application now closes automatically when X button pressed.) |
(Scala contribution added.) |
||
Line 1,226: | Line 1,226: | ||
end</lang> |
end</lang> |
||
=={{header|Scala}}== |
|||
===Java Swing Interoperability=== |
|||
<lang Scala>import java.awt.event.{KeyAdapter, KeyEvent} |
|||
import javax.swing.{JFrame, JLabel, WindowConstants} |
|||
object KeyboardMacroDemo extends App { |
|||
val directions = "<html><b>Ctrl-S</b> to show frame title<br>" + "<b>Ctrl-H</b> to hide it</html>" |
|||
new JFrame { |
|||
add(new JLabel(directions)) |
|||
addKeyListener(new KeyAdapter() { |
|||
override def keyReleased(e: KeyEvent): Unit = { |
|||
if (e.isControlDown && e.getKeyCode == KeyEvent.VK_S) setTitle("Hello there") |
|||
else if (e.isControlDown && e.getKeyCode == KeyEvent.VK_H) setTitle("") |
|||
} |
|||
}) |
|||
pack() |
|||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) |
|||
setVisible(true) |
|||
} |
|||
}</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
{{libheader|Tk}} |
{{libheader|Tk}} |
||
All Tk bindings are bound to a context that is no wider than a particular application and is frequently smaller (e.g., a single dialog box or an individual widget). |
All Tk bindings are bound to a context that is no wider than a particular application and is frequently smaller (e.g., a single dialog box or an individual widget). |
||
<lang tcl>package require Tk |
<lang tcl>package require Tk |