Skip to content

Commit 3a4c277

Browse files
committed
Keyboard shortcuts + menu items
1 parent 5bd173a commit 3a4c277

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

p5js/src/main/kotlin/p5jsEditor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import kotlinx.html.dom.createHTMLDocument
2323
import kotlinx.html.dom.serialize
2424
import kotlinx.serialization.json.*
2525
import processing.app.*
26+
import processing.app.Messages.Companion.log
2627
import processing.app.syntax.JEditTextArea
2728
import processing.app.syntax.PdeTextArea
2829
import processing.app.syntax.PdeTextAreaDefaults
@@ -142,7 +143,17 @@ class p5jsEditor(base: Base, path: String?, state: EditorState?, mode: Mode?): E
142143
// }
143144

144145
override fun buildSketchMenu(): JMenu {
145-
return super.buildSketchMenu(arrayOf())
146+
val runItem = Toolkit.newJMenuItem(Language.text("menu.sketch.run"), 'R'.code)
147+
runItem.addActionListener { e: ActionEvent? -> toolbar.handleRun(0) }
148+
149+
// val presentItem = Toolkit.newJMenuItemShift(Language.text("menu.sketch.present"), 'R'.code)
150+
// presentItem.addActionListener { e: ActionEvent? -> toolbar.handleRun(0) }
151+
152+
val stopItem = JMenuItem(Language.text("menu.sketch.stop"))
153+
stopItem.addActionListener { e: ActionEvent? ->
154+
toolbar.handleStop()
155+
}
156+
return super.buildSketchMenu(arrayOf(runItem, stopItem))
146157
}
147158

148159
override fun handleImportLibrary(name: String?) {

0 commit comments

Comments
 (0)