mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
Un/Fullscreen, SetTitle in Kitchen Sink
This commit is contained in:
parent
98cc356b92
commit
e12762a584
5 changed files with 52 additions and 44 deletions
6
v2/test/kitchensink/frontend/package-lock.json
generated
6
v2/test/kitchensink/frontend/package-lock.json
generated
|
|
@ -135,9 +135,9 @@
|
|||
}
|
||||
},
|
||||
"@wails/runtime": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@wails/runtime/-/runtime-1.2.0.tgz",
|
||||
"integrity": "sha512-tIyQdjM+/zZyFNB2dgeUA7ln2T3F8skyv6w2oa3ONRcRF5JvDWto8vh+4B2yrkVNLBAQYO0xRHL+4G9wVQHYQQ==",
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@wails/runtime/-/runtime-1.2.2.tgz",
|
||||
"integrity": "sha512-sZlW83ZXldcb4Kbkcl1MZ/iPdSbMQtlCM60b3VcCehwYqR/aM/cKZPLm/HbOwvyRhkv4/Uo6QPlwlB13UUFhSA==",
|
||||
"dev": true
|
||||
},
|
||||
"alphanum-sort": {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
"@rollup/plugin-commonjs": "^11.0.0",
|
||||
"@rollup/plugin-node-resolve": "^7.0.0",
|
||||
"@rollup/plugin-url": "^5.0.1",
|
||||
"@wails/runtime": "^1.2.0",
|
||||
"@wails/runtime": "^1.2.2",
|
||||
"focus-visible": "^5.2.0",
|
||||
"halfmoon": "^1.1.1",
|
||||
"postcss": "^8.1.7",
|
||||
|
|
|
|||
|
|
@ -7,51 +7,37 @@
|
|||
|
||||
var message = '';
|
||||
var isJs = false;
|
||||
var title = '';
|
||||
|
||||
let windowActions = ["Maximise", "Unmaximise", "Minimise", "Unminimise", "Center", "Show", "Hide", "SetSize", "SetPosition", "Close"]
|
||||
|
||||
let windowActions = ["SetTitle", "Fullscreen", "UnFullscreen", "Maximise", "Unmaximise", "Minimise", "Unminimise", "Center", "Show", "Hide", "SetSize", "SetPosition", "Close"]
|
||||
var disabledActions = ['Show', 'Unminimise'];
|
||||
var windowAction = windowActions[0];
|
||||
|
||||
$: windowRuntime = lang == 'Javascript' ? Window : backend.main.Window;
|
||||
$: lang = isJs ? 'Javascript' : 'Go';
|
||||
|
||||
var id = "Window";
|
||||
|
||||
function processAction() {
|
||||
if ( lang == 'Javascript' ) {
|
||||
switch( windowAction ) {
|
||||
case 'SetSize':
|
||||
Window.SetSize(sizeWidth, sizeHeight);
|
||||
break;
|
||||
case 'SetPosition':
|
||||
Window.SetPosition(positionX, positionY);
|
||||
break;
|
||||
case 'Hide':
|
||||
Window.Hide();
|
||||
setTimeout( Window.Show, 3000 );
|
||||
case 'Minimise':
|
||||
Window.Hide();
|
||||
setTimeout( Window.Unminimise, 3000 );
|
||||
default:
|
||||
Window[windowAction]();
|
||||
}
|
||||
} else {
|
||||
switch( windowAction ) {
|
||||
case 'SetSize':
|
||||
backend.main.Window.SetSize(sizeWidth, sizeHeight);
|
||||
break;
|
||||
case 'SetPosition':
|
||||
backend.main.Window.SetPosition(positionX, positionY);
|
||||
break;
|
||||
case 'Hide':
|
||||
backend.main.Window.Hide();
|
||||
setTimeout( backend.main.Window.Show, 3000 );
|
||||
case 'Minimise':
|
||||
backend.main.Window.Minimise();
|
||||
setTimeout( backend.main.Window.Unminimise, 3000 );
|
||||
default:
|
||||
backend.main.Window[windowAction]();
|
||||
break;
|
||||
}
|
||||
|
||||
switch( windowAction ) {
|
||||
case 'SetSize':
|
||||
windowRuntime.SetSize(sizeWidth, sizeHeight);
|
||||
break;
|
||||
case 'SetPosition':
|
||||
windowRuntime.SetPosition(positionX, positionY);
|
||||
break;
|
||||
case 'SetTitle':
|
||||
windowRuntime.SetTitle(title);
|
||||
break;
|
||||
case 'Hide':
|
||||
windowRuntime.Hide();
|
||||
setTimeout( windowRuntime.Show, 3000 );
|
||||
case 'Minimise':
|
||||
windowRuntime.Hide();
|
||||
setTimeout( windowRuntime.Unminimise, 3000 );
|
||||
default:
|
||||
windowRuntime[windowAction]();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +55,9 @@
|
|||
case 'SetPosition':
|
||||
params = positionX + ", " + positionY;
|
||||
break;
|
||||
case 'SetTitle':
|
||||
params = `'` + title.replace(`"`, `\"`) + `'`;
|
||||
break;
|
||||
default:
|
||||
params = '';
|
||||
break;
|
||||
|
|
@ -76,7 +65,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
$: testcodeJs = "import { Window } from '@wails/runtime';\Window." + windowAction + "(" + params + ");";
|
||||
$: testcodeJs = "import { Window } from '@wails/runtime';\nWindow." + windowAction + "(" + params + ");";
|
||||
$: testcodeGo = '// runtime is given through WailsInit()\nruntime.Window.' + windowAction + '(' + params + ')';
|
||||
|
||||
</script>
|
||||
|
|
@ -88,7 +77,7 @@
|
|||
<div>Select Window Method</div>
|
||||
{#each windowActions as option, index}
|
||||
<div class="custom-radio">
|
||||
<input type="radio" name="window" bind:group="{windowAction}" id="{id}-{option}" value="{option}" disabled={['Show', 'Unminimise'].includes(option)}>
|
||||
<input type="radio" name="window" bind:group="{windowAction}" id="{id}-{option}" value="{option}" disabled={disabledActions.includes(option)}>
|
||||
<label for="{id}-{option}">{option}
|
||||
{#if option == 'Hide' } - Show() will be called after 3 seconds {/if}
|
||||
{#if option == 'Minimise' } - Unminimise() will be called after 3 seconds {/if}
|
||||
|
|
@ -106,6 +95,12 @@
|
|||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if option == "SetTitle"}
|
||||
{#if windowAction == "SetTitle" }
|
||||
<div class="form-inline form-group numberInputGroup">Title: <input type="text" class="form-control" bind:value={title}></div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ func main() {
|
|||
Mac: &mac.Options{
|
||||
WebviewIsTransparent: true,
|
||||
WindowBackgroundIsTranslucent: true,
|
||||
TitleBar: mac.TitleBarHiddenInset(),
|
||||
// TitleBar: mac.TitleBarHiddenInset(),
|
||||
},
|
||||
LogLevel: logger.TRACE,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -16,6 +16,19 @@ func (w *Window) WailsInit(runtime *wails.Runtime) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (w *Window) SetTitle(title string) {
|
||||
println("In SetTitle:", title)
|
||||
w.runtime.Window.SetTitle(title)
|
||||
}
|
||||
|
||||
func (w *Window) Fullscreen() {
|
||||
w.runtime.Window.Fullscreen()
|
||||
}
|
||||
|
||||
func (w *Window) UnFullscreen() {
|
||||
w.runtime.Window.UnFullscreen()
|
||||
}
|
||||
|
||||
func (w *Window) Maximise() {
|
||||
w.runtime.Window.Maximise()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue