Skip to content

Commit c7a89d8

Browse files
committed
Added ability to present sketches
1 parent 3a4c277 commit c7a89d8

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

p5js/js/electron/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const createWindow = () => {
66
width: 400,
77
height: 400,
88
show: false,
9+
fullscreen: process.env.PRESENT == "true",
910
autoHideMenuBar: true,
1011
alwaysOnTop: false,
1112
webPreferences: {

p5js/src/main/kotlin/p5jsEditor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ class p5jsEditor(base: Base, path: String?, state: EditorState?, mode: Mode?): E
146146
val runItem = Toolkit.newJMenuItem(Language.text("menu.sketch.run"), 'R'.code)
147147
runItem.addActionListener { e: ActionEvent? -> toolbar.handleRun(0) }
148148

149-
// val presentItem = Toolkit.newJMenuItemShift(Language.text("menu.sketch.present"), 'R'.code)
150-
// presentItem.addActionListener { e: ActionEvent? -> toolbar.handleRun(0) }
149+
val presentItem = Toolkit.newJMenuItemShift(Language.text("menu.sketch.present"), 'R'.code)
150+
presentItem.addActionListener { e: ActionEvent? -> toolbar.handleRun(java.awt.Event.SHIFT_MASK) }
151151

152152
val stopItem = JMenuItem(Language.text("menu.sketch.stop"))
153153
stopItem.addActionListener { e: ActionEvent? ->
154154
toolbar.handleStop()
155155
}
156-
return super.buildSketchMenu(arrayOf(runItem, stopItem))
156+
return super.buildSketchMenu(arrayOf(runItem, presentItem, stopItem))
157157
}
158158

159159
override fun handleImportLibrary(name: String?) {

p5js/src/main/kotlin/p5jsEditorToolbar.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package processing.p5js
22

3-
import kotlinx.coroutines.CoroutineScope
43
import kotlinx.coroutines.launch
5-
import kotlinx.coroutines.sync.withLock
64
import processing.app.ui.EditorToolbar
5+
import java.awt.event.ActionEvent
76

87
class p5jsEditorToolbar(editor: p5jsEditor) : EditorToolbar(editor) {
98
override fun handleRun(modifiers: Int) {
109
val editor = editor as p5jsEditor
1110
editor.sketch.save()
1211

12+
val present = (modifiers and ActionEvent.SHIFT_MASK) != 0
13+
1314
// TODO: Re-create index.html here instead of on saveAs/rename/delete of code?
1415
editor.createIndexHtml()
1516

@@ -20,7 +21,7 @@ class p5jsEditorToolbar(editor: p5jsEditor) : EditorToolbar(editor) {
2021
// TODO: Smarter way to only install deps when needed?
2122
// --dangerously-allow-all-builds allows electron in particular to install properly
2223
editor.runCommand("pnpm install --dangerously-allow-all-builds")
23-
editor.runCommand("pnpm sketch:start") {
24+
editor.runCommand("PRESENT=$present pnpm sketch:start") {
2425
deactivateRun()
2526
editor.statusEmpty()
2627
}

0 commit comments

Comments
 (0)