git0 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/assets/js/c3a618e1.965a31da.js +1 -1
- package/docs/functions/index.html +2 -2
- package/docs-config/src/functions/index.md +1 -1
- package/package.json +2 -1
- package/readme.md +18 -30
- package/src/fm.js +1130 -0
- package/src/github-api.js +14 -15
- package/TypeScript-React-Starter/LICENSE +0 -21
- package/TypeScript-React-Starter/README-CRA.md +0 -1281
- package/TypeScript-React-Starter/README.md +0 -810
- package/TypeScript-React-Starter/package.json +0 -28
- package/TypeScript-React-Starter/public/favicon.ico +0 -0
- package/TypeScript-React-Starter/public/index.html +0 -31
- package/TypeScript-React-Starter/src/App.css +0 -24
- package/TypeScript-React-Starter/src/App.test.tsx +0 -8
- package/TypeScript-React-Starter/src/App.tsx +0 -23
- package/TypeScript-React-Starter/src/actions/index.tsx +0 -24
- package/TypeScript-React-Starter/src/components/Hello.css +0 -13
- package/TypeScript-React-Starter/src/components/Hello.test.tsx +0 -30
- package/TypeScript-React-Starter/src/components/Hello.tsx +0 -35
- package/TypeScript-React-Starter/src/constants/index.tsx +0 -6
- package/TypeScript-React-Starter/src/containers/Hello.tsx +0 -20
- package/TypeScript-React-Starter/src/index.css +0 -5
- package/TypeScript-React-Starter/src/index.tsx +0 -22
- package/TypeScript-React-Starter/src/logo.svg +0 -7
- package/TypeScript-React-Starter/src/reducers/index.tsx +0 -15
- package/TypeScript-React-Starter/src/types/index.tsx +0 -5
- package/TypeScript-React-Starter/tsconfig.json +0 -29
- package/TypeScript-React-Starter/tslint.json +0 -11
- package/TypeScript-React-Starter/yarn.lock +0 -4785
- package/svelte-nodegui/.all-contributorsrc +0 -60
- package/svelte-nodegui/.vscode/launch.json +0 -29
- package/svelte-nodegui/CHANGELOG.md +0 -153
- package/svelte-nodegui/LICENSE +0 -22
- package/svelte-nodegui/README.md +0 -151
- package/svelte-nodegui/demo/.editorconfig +0 -15
- package/svelte-nodegui/demo/.vscode/extensions.json +0 -3
- package/svelte-nodegui/demo/livereload.js +0 -29
- package/svelte-nodegui/demo/package-lock.json +0 -3514
- package/svelte-nodegui/demo/package.json +0 -35
- package/svelte-nodegui/demo/src/App.svelte +0 -29
- package/svelte-nodegui/demo/src/app.ts +0 -31
- package/svelte-nodegui/demo/tsconfig.json +0 -40
- package/svelte-nodegui/demo/webpack.config.js +0 -110
- package/svelte-nodegui/extras/assets/kitchen.png +0 -0
- package/svelte-nodegui/extras/assets/nodegui.png +0 -0
- package/svelte-nodegui/extras/assets/nodegui_white.png +0 -0
- package/svelte-nodegui/extras/assets/start_icon.png +0 -0
- package/svelte-nodegui/extras/legal/logo/thanks.md +0 -13
- package/svelte-nodegui/extras/legal/yode/LICENSE +0 -21
- package/svelte-nodegui/extras/legal/yoga/LICENSE +0 -0
- package/svelte-nodegui/extras/logo/nodegui-circle.png +0 -0
- package/svelte-nodegui/extras/logo/nodegui.png +0 -0
- package/svelte-nodegui/extras/logo/nodegui.svg +0 -4
- package/svelte-nodegui/nativescript-svelte-todo.gif +0 -0
- package/svelte-nodegui/package-lock.json +0 -1749
- package/svelte-nodegui/package.json +0 -44
- package/svelte-nodegui/repl-workers/bundler/commonjs.js +0 -58
- package/svelte-nodegui/repl-workers/bundler/index.js +0 -353
- package/svelte-nodegui/repl-workers/package-lock.json +0 -484
- package/svelte-nodegui/repl-workers/package.json +0 -21
- package/svelte-nodegui/repl-workers/rollup.config.js +0 -21
- package/svelte-nodegui/rollup.config.js +0 -81
- package/svelte-nodegui/scripts/create-pkg.js +0 -42
- package/svelte-nodegui/src/components/AsComponent.svelte +0 -16
- package/svelte-nodegui/src/components/SlotComponent.svelte +0 -4
- package/svelte-nodegui/src/components/Template.svelte +0 -10
- package/svelte-nodegui/src/components/Template.svelte.d.ts +0 -6
- package/svelte-nodegui/src/components/index.ts +0 -2
- package/svelte-nodegui/src/dom/index.ts +0 -132
- package/svelte-nodegui/src/dom/nativescript-vue-next/LICENCE +0 -21
- package/svelte-nodegui/src/dom/nativescript-vue-next/index.ts +0 -19
- package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/index.ts +0 -21
- package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/nodes.ts +0 -890
- package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/registry.ts +0 -262
- package/svelte-nodegui/src/dom/nativescript-vue-next/runtime/runtimeHelpers.ts +0 -20
- package/svelte-nodegui/src/dom/react-nodegui/LICENSE +0 -21
- package/svelte-nodegui/src/dom/react-nodegui/src/components/AbstractComponents/RNAbstractButton.ts +0 -67
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Action/RNAction.ts +0 -146
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Action/index.ts +0 -37
- package/svelte-nodegui/src/dom/react-nodegui/src/components/AnimatedImage/RNAnimatedImage.ts +0 -76
- package/svelte-nodegui/src/dom/react-nodegui/src/components/AnimatedImage/index.ts +0 -45
- package/svelte-nodegui/src/dom/react-nodegui/src/components/BoxView/RNBoxView.ts +0 -99
- package/svelte-nodegui/src/dom/react-nodegui/src/components/BoxView/index.ts +0 -49
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Button/RNButton.ts +0 -71
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Button/index.ts +0 -49
- package/svelte-nodegui/src/dom/react-nodegui/src/components/CheckBox/RNCheckBox.ts +0 -71
- package/svelte-nodegui/src/dom/react-nodegui/src/components/CheckBox/index.ts +0 -50
- package/svelte-nodegui/src/dom/react-nodegui/src/components/ComboBox/RNComboBox.ts +0 -118
- package/svelte-nodegui/src/dom/react-nodegui/src/components/ComboBox/index.ts +0 -50
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Dial/RNDial.ts +0 -69
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Dial/index.ts +0 -41
- package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridColumn/RNGridColumn.ts +0 -95
- package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridColumn/index.ts +0 -49
- package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridRow/RNGridRow.ts +0 -141
- package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/GridRow/index.ts +0 -47
- package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/RNGridView.ts +0 -185
- package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/index.ts +0 -51
- package/svelte-nodegui/src/dom/react-nodegui/src/components/GridView/utils.ts +0 -59
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Image/RNImage.ts +0 -135
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Image/index.ts +0 -46
- package/svelte-nodegui/src/dom/react-nodegui/src/components/LineEdit/RNLineEdit.ts +0 -82
- package/svelte-nodegui/src/dom/react-nodegui/src/components/LineEdit/index.ts +0 -41
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Menu/RNMenu.ts +0 -49
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Menu/index.ts +0 -44
- package/svelte-nodegui/src/dom/react-nodegui/src/components/MenuBar/RNMenuBar.ts +0 -51
- package/svelte-nodegui/src/dom/react-nodegui/src/components/MenuBar/index.ts +0 -42
- package/svelte-nodegui/src/dom/react-nodegui/src/components/PlainTextEdit/RNPlainTextEdit.ts +0 -82
- package/svelte-nodegui/src/dom/react-nodegui/src/components/PlainTextEdit/index.ts +0 -44
- package/svelte-nodegui/src/dom/react-nodegui/src/components/ProgressBar/RNProgressBar.ts +0 -78
- package/svelte-nodegui/src/dom/react-nodegui/src/components/ProgressBar/index.ts +0 -43
- package/svelte-nodegui/src/dom/react-nodegui/src/components/RadioButton/RNRadioButton.ts +0 -50
- package/svelte-nodegui/src/dom/react-nodegui/src/components/RadioButton/index.ts +0 -43
- package/svelte-nodegui/src/dom/react-nodegui/src/components/ScrollArea/RNScrollArea.ts +0 -51
- package/svelte-nodegui/src/dom/react-nodegui/src/components/ScrollArea/index.ts +0 -44
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Slider/RNSlider.ts +0 -97
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Slider/index.ts +0 -46
- package/svelte-nodegui/src/dom/react-nodegui/src/components/SpinBox/RNSpinBox.ts +0 -88
- package/svelte-nodegui/src/dom/react-nodegui/src/components/SpinBox/index.ts +0 -49
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Svg/RNSvg.ts +0 -67
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Svg/index.ts +0 -43
- package/svelte-nodegui/src/dom/react-nodegui/src/components/SystemTrayIcon/RNSystemTrayIcon.ts +0 -141
- package/svelte-nodegui/src/dom/react-nodegui/src/components/SystemTrayIcon/index.ts +0 -43
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Tab/RNTab.ts +0 -69
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Tab/index.ts +0 -48
- package/svelte-nodegui/src/dom/react-nodegui/src/components/TabItem/RNTabItem.ts +0 -72
- package/svelte-nodegui/src/dom/react-nodegui/src/components/TabItem/index.ts +0 -40
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Text/RNText.ts +0 -65
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Text/index.ts +0 -49
- package/svelte-nodegui/src/dom/react-nodegui/src/components/View/RNView.ts +0 -306
- package/svelte-nodegui/src/dom/react-nodegui/src/components/View/index.ts +0 -44
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Window/RNWindow.ts +0 -66
- package/svelte-nodegui/src/dom/react-nodegui/src/components/Window/index.ts +0 -50
- package/svelte-nodegui/src/dom/react-nodegui/src/components/config.ts +0 -95
- package/svelte-nodegui/src/dom/react-nodegui/src/index.ts +0 -52
- package/svelte-nodegui/src/dom/react-nodegui/src/reconciler/index.ts +0 -226
- package/svelte-nodegui/src/dom/react-nodegui/src/utils/decoupleFromReact.ts +0 -2
- package/svelte-nodegui/src/dom/react-nodegui/src/utils/helpers.ts +0 -14
- package/svelte-nodegui/src/dom/shared/Logger.ts +0 -16
- package/svelte-nodegui/src/dom/shared/index.ts +0 -1
- package/svelte-nodegui/src/dom/svelte/HeadElement.ts +0 -41
- package/svelte-nodegui/src/dom/svelte/RNObject.ts +0 -95
- package/svelte-nodegui/src/dom/svelte/StyleElement.ts +0 -92
- package/svelte-nodegui/src/dom/svelte/SvelteNodeGUIDocument.ts +0 -124
- package/svelte-nodegui/src/dom/svelte/TemplateElement.ts +0 -16
- package/svelte-nodegui/src/dom/svelte-elements.ts +0 -111
- package/svelte-nodegui/src/index.ts +0 -62
- package/svelte-nodegui/src/svelte-nodegui.ts +0 -159
- package/svelte-nodegui/src/transitions/bezier.ts +0 -112
- package/svelte-nodegui/src/transitions/index.ts +0 -227
- package/svelte-nodegui/tsconfig.json +0 -19
- package/svelte-nodegui/website/README.md +0 -33
- package/svelte-nodegui/website/blog/2019-05-30-welcome.md +0 -12
- package/svelte-nodegui/website/docs/api/classes/renderer.md +0 -49
- package/svelte-nodegui/website/docs/api/classes/rnaction.md +0 -608
- package/svelte-nodegui/website/docs/api/classes/rngridcolumn.md +0 -232
- package/svelte-nodegui/website/docs/api/classes/rngridrow.md +0 -247
- package/svelte-nodegui/website/docs/api/classes/rnmenu.md +0 -1337
- package/svelte-nodegui/website/docs/api/classes/rnmenubar.md +0 -1341
- package/svelte-nodegui/website/docs/api/globals.md +0 -832
- package/svelte-nodegui/website/docs/api/index.md +0 -0
- package/svelte-nodegui/website/docs/api/interfaces/_react_proxy_.reactproxycomponent.md +0 -38
- package/svelte-nodegui/website/docs/api/interfaces/abstractbuttonprops.md +0 -306
- package/svelte-nodegui/website/docs/api/interfaces/actionprops.md +0 -115
- package/svelte-nodegui/website/docs/api/interfaces/animatedimageprops.md +0 -297
- package/svelte-nodegui/website/docs/api/interfaces/boxviewprops.md +0 -245
- package/svelte-nodegui/website/docs/api/interfaces/buttonprops.md +0 -313
- package/svelte-nodegui/website/docs/api/interfaces/checkboxprops.md +0 -313
- package/svelte-nodegui/website/docs/api/interfaces/comboboxprops.md +0 -343
- package/svelte-nodegui/website/docs/api/interfaces/datawithoffset.md +0 -32
- package/svelte-nodegui/website/docs/api/interfaces/dialprops.md +0 -259
- package/svelte-nodegui/website/docs/api/interfaces/gridviewprops.md +0 -273
- package/svelte-nodegui/website/docs/api/interfaces/imageprops.md +0 -311
- package/svelte-nodegui/website/docs/api/interfaces/lineeditprops.md +0 -266
- package/svelte-nodegui/website/docs/api/interfaces/menubarprops.md +0 -245
- package/svelte-nodegui/website/docs/api/interfaces/menuprops.md +0 -245
- package/svelte-nodegui/website/docs/api/interfaces/plaintexteditprops.md +0 -259
- package/svelte-nodegui/website/docs/api/interfaces/progressbarprops.md +0 -266
- package/svelte-nodegui/website/docs/api/interfaces/radiobuttonprops.md +0 -282
- package/svelte-nodegui/website/docs/api/interfaces/scrollareaprops.md +0 -245
- package/svelte-nodegui/website/docs/api/interfaces/sliderprops.md +0 -329
- package/svelte-nodegui/website/docs/api/interfaces/spinboxprops.md +0 -273
- package/svelte-nodegui/website/docs/api/interfaces/systemtrayiconprops.md +0 -97
- package/svelte-nodegui/website/docs/api/interfaces/tabitemprops.md +0 -28
- package/svelte-nodegui/website/docs/api/interfaces/tabprops.md +0 -245
- package/svelte-nodegui/website/docs/api/interfaces/textprops.md +0 -277
- package/svelte-nodegui/website/docs/api/interfaces/viewprops.md +0 -261
- package/svelte-nodegui/website/docs/api/interfaces/windowprops.md +0 -245
- package/svelte-nodegui/website/docs/api/modules/_react_proxy_.md +0 -29
- package/svelte-nodegui/website/docs/doc1.md +0 -162
- package/svelte-nodegui/website/docs/guides/custom-nodegui-native-plugin.md +0 -6
- package/svelte-nodegui/website/docs/guides/debugging-in-vscode.md +0 -39
- package/svelte-nodegui/website/docs/guides/debugging.md +0 -59
- package/svelte-nodegui/website/docs/guides/getting-started.md +0 -141
- package/svelte-nodegui/website/docs/guides/handle-events.md +0 -188
- package/svelte-nodegui/website/docs/guides/images.md +0 -62
- package/svelte-nodegui/website/docs/guides/layout.md +0 -281
- package/svelte-nodegui/website/docs/guides/networking.md +0 -31
- package/svelte-nodegui/website/docs/guides/packaging.md +0 -32
- package/svelte-nodegui/website/docs/guides/scroll-view.md +0 -69
- package/svelte-nodegui/website/docs/guides/styling.md +0 -208
- package/svelte-nodegui/website/docs/guides/tutorial.md +0 -82
- package/svelte-nodegui/website/docs/guides/using-native-node-modules.md +0 -55
- package/svelte-nodegui/website/docs/mdx.md +0 -22
- package/svelte-nodegui/website/docs/scripts/fixdocs.js +0 -21
- package/svelte-nodegui/website/docusaurus.config.js +0 -131
- package/svelte-nodegui/website/package.json +0 -33
- package/svelte-nodegui/website/sidebars.js +0 -77
- package/svelte-nodegui/website/src/components/CodeExample.js +0 -42
- package/svelte-nodegui/website/src/components/CreateNativeApps.js +0 -46
- package/svelte-nodegui/website/src/components/Features.js +0 -62
- package/svelte-nodegui/website/src/components/Hero.js +0 -85
- package/svelte-nodegui/website/src/components/SplitView.js +0 -18
- package/svelte-nodegui/website/src/components/Talks.js +0 -68
- package/svelte-nodegui/website/src/components/Try.js +0 -83
- package/svelte-nodegui/website/src/components/common.js +0 -41
- package/svelte-nodegui/website/src/components/styles.css +0 -61
- package/svelte-nodegui/website/src/css/custom.css +0 -34
- package/svelte-nodegui/website/src/pages/index.js +0 -32
- package/svelte-nodegui/website/src/pages/styles.module.css +0 -35
- package/svelte-nodegui/website/static/CNAME +0 -1
- package/svelte-nodegui/website/static/img/box-layout-1.png +0 -0
- package/svelte-nodegui/website/static/img/box-layout-2.png +0 -0
- package/svelte-nodegui/website/static/img/code-sample.png +0 -0
- package/svelte-nodegui/website/static/img/demo.png +0 -0
- package/svelte-nodegui/website/static/img/favicon.ico +0 -0
- package/svelte-nodegui/website/static/img/flex-layout-1.png +0 -0
- package/svelte-nodegui/website/static/img/grid-layout-1.png +0 -0
- package/svelte-nodegui/website/static/img/logo-circle.png +0 -0
- package/svelte-nodegui/website/static/img/logo.png +0 -0
- package/svelte-nodegui/website/static/img/logo.svg +0 -5
- package/svelte-nodegui/website/static/img/logox200.png +0 -0
- package/svelte-nodegui/website/static/img/undraw_building_websites.svg +0 -1
- package/svelte-nodegui/website/static/img/undraw_code_review.svg +0 -1
- package/svelte-nodegui/website/static/img/undraw_docusaurus_mountain.svg +0 -170
- package/svelte-nodegui/website/static/img/undraw_docusaurus_react.svg +0 -169
- package/svelte-nodegui/website/static/img/undraw_docusaurus_tree.svg +0 -1
- package/svelte-nodegui/website/static/img/undraw_react.svg +0 -1
- package/svelte-nodegui/website/static/img/undraw_website_setup.svg +0 -1
- package/svelte-nodegui/website/static/img/undraw_windows.svg +0 -11
- package/svelte-nodegui/website/website/sidebars.js +0 -32
- package/svelte-nodegui/website/yarn.lock +0 -10533
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_label: Handle Events
|
|
3
|
-
title: Handle Events
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Svelte NodeGui allows you to listen to various events that might originate from the underlying Qt widgets. These events can either be a simple button click or a text change on a LineEdit or even something like window being hidden and shown.
|
|
7
|
-
|
|
8
|
-
In order to do this we need to attach an event listener to the respective widget.
|
|
9
|
-
|
|
10
|
-
Technically, the event listener is a NodeJs [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) instance that listens to events from the underlying Qt widget. The native Qt widget would send all the events to the event emitter in Svelte NodeGui world and the user can essentially subscribe to it.
|
|
11
|
-
|
|
12
|
-
Lets see an example to see how this looks in practice.
|
|
13
|
-
|
|
14
|
-
## Event handling
|
|
15
|
-
|
|
16
|
-
The following example demonstrates how to add a clicked event listener to a button widget.
|
|
17
|
-
|
|
18
|
-
<img src="https://github.com/nodegui/react-nodegui/releases/download/assets/events-react.gif" alt="event example" style={{width: '100%', maxWidth: 400}}/>
|
|
19
|
-
|
|
20
|
-
```html
|
|
21
|
-
<script lang="ts">
|
|
22
|
-
import { onMount } from "svelte";
|
|
23
|
-
let win;
|
|
24
|
-
|
|
25
|
-
function onClicked(checked){
|
|
26
|
-
console.log("the button was clicked", checked);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
onMount(() => {
|
|
30
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
31
|
-
win.nativeView.show();
|
|
32
|
-
return () => {
|
|
33
|
-
delete (window as any).win;
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
<window bind:this={win}>
|
|
39
|
-
<button on:clicked={onClicked} text="Click me"/>
|
|
40
|
-
</window>
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The [`on:` directive](https://svelte.dev/docs#on_component_event) accepts an event name (e.g. "clicked") and a corresponding event handler function.
|
|
44
|
-
|
|
45
|
-
Internally, Qt widgets in nodegui has two types of events:
|
|
46
|
-
|
|
47
|
-
- Signals: In short these are basically different for different widgets. So a button may have `clicked` and `pressed` signals, while a LineEdit may have, say, the `textChanged` signal.
|
|
48
|
-
- QEvents: These are common set of events for all the widgets/qobjects in NodeGui world. These are also helpful at times but typically you would end up using signals more than these common events.
|
|
49
|
-
|
|
50
|
-
In Svelte NodeGui you can listen to both Signals and QEvents using the same `on:` directive.
|
|
51
|
-
|
|
52
|
-
<!-- ### useEventHandler hook and typescript support
|
|
53
|
-
|
|
54
|
-
Although you can pass in an object with event handlers to the `on:` directive, its not the most efficient way. This is because everytime the render is called the `on:` directive will get a new object meaning the widget will re-render every time. To solve for this we have `useEventHandler` hook.
|
|
55
|
-
|
|
56
|
-
```ts
|
|
57
|
-
import React from "react";
|
|
58
|
-
import {
|
|
59
|
-
Renderer,
|
|
60
|
-
Button,
|
|
61
|
-
Window,
|
|
62
|
-
useEventHandler
|
|
63
|
-
} from "@nodegui/react-nodegui";
|
|
64
|
-
import { QPushButtonSignals } from "@nodegui/nodegui";
|
|
65
|
-
|
|
66
|
-
const App = () => {
|
|
67
|
-
const buttonHandler = useEventHandler<QPushButtonSignals>(
|
|
68
|
-
{
|
|
69
|
-
clicked: () => {
|
|
70
|
-
console.log("the button was clicked");
|
|
71
|
-
},
|
|
72
|
-
pressed: () => {
|
|
73
|
-
console.log("button was pressed");
|
|
74
|
-
},
|
|
75
|
-
objectNameChanged: objectName => {
|
|
76
|
-
console.log("new object name", objectName);
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
[]
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<Window>
|
|
84
|
-
<Button text={"Click me"} on={buttonHandler} />
|
|
85
|
-
</Window>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
Renderer.render(<App />);
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
In a nutshell, the above code uses the `useEventHandler` hook which is a wrapper over `useMemo`.
|
|
93
|
-
This means, the buttonHandler remains same on every render call and hence the `on:` directive to Button doesnt change.
|
|
94
|
-
|
|
95
|
-
Here `objectNameChanged` is a QEvent while `clicked` and `pressed` are signals. As an app developer it really doesnt mean much but internally they are both two different things in Qt and Svelte NodeGui allows you to use both of them using a single familiar `on:` directive.
|
|
96
|
-
|
|
97
|
-
Also, another point you see in this typescript code is the QPushButtonSignals. The QPushButtonSignals is a type that allows autocompletion of event handlers as you type them. -->
|
|
98
|
-
|
|
99
|
-
### How do I know which events are supported ?
|
|
100
|
-
|
|
101
|
-
In order to find all the supported events for a widget you can take a look at
|
|
102
|
-
|
|
103
|
-
#### All Signals for the widgets:
|
|
104
|
-
|
|
105
|
-
- [https://docs.nodegui.org/docs/api/generated/globals/#interfaces](https://docs.nodegui.org/docs/api/generated/globals/#interfaces)
|
|
106
|
-
- [https://docs.nodegui.org/docs/api/generated/globals/#type-aliases](https://docs.nodegui.org/docs/api/generated/globals/#type-aliases)
|
|
107
|
-
|
|
108
|
-
<!-- You can subscribe to a signal like so:
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
import React from "react";
|
|
112
|
-
import {
|
|
113
|
-
Renderer,
|
|
114
|
-
Button,
|
|
115
|
-
Window,
|
|
116
|
-
useEventHandler
|
|
117
|
-
} from "@nodegui/react-nodegui";
|
|
118
|
-
import { QPushButtonSignals } from "@nodegui/nodegui";
|
|
119
|
-
|
|
120
|
-
const App = () => {
|
|
121
|
-
const buttonHandler = useEventHandler<QPushButtonSignals>(
|
|
122
|
-
{
|
|
123
|
-
clicked: () => {
|
|
124
|
-
console.log("the button was clicked");
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
[]
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<Window>
|
|
132
|
-
<Button text={"Click me"} on={buttonHandler} />
|
|
133
|
-
</Window>
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
Renderer.render(<App />);
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
The value you receive in the callback depends on the signal. Refer to respective signal docs for more details. All the handlers are also typed. So if you are using typescript you should get correct autocomplete for it. -->
|
|
141
|
-
|
|
142
|
-
#### All common QEvents for the widgets
|
|
143
|
-
|
|
144
|
-
In nodegui all these common QEvents are represented under an enum type: [WidgetEventTypes](https://docs.nodegui.org/docs/api/generated/enums/widgeteventtypes)
|
|
145
|
-
|
|
146
|
-
You can subscribe to a QEvent like so:
|
|
147
|
-
|
|
148
|
-
```html
|
|
149
|
-
<script lang="ts">
|
|
150
|
-
import { onMount } from "svelte";
|
|
151
|
-
import { QLabelSignals, QMouseEvent, WidgetEventTypes } from "@nodegui/nodegui";
|
|
152
|
-
let win;
|
|
153
|
-
|
|
154
|
-
function onMouseMove(checked){
|
|
155
|
-
const mouseEvt = new QMouseEvent(nativeEvt);
|
|
156
|
-
console.log("mouseMoved at: ", { x: mouseEvt.x(), y: mouseEvt.y() });
|
|
157
|
-
}
|
|
158
|
-
function onMouseButtonPress(checked){
|
|
159
|
-
console.log("mouse button was pressed");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
onMount(() => {
|
|
163
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
164
|
-
win.nativeView.show();
|
|
165
|
-
return () => {
|
|
166
|
-
delete (window as any).win;
|
|
167
|
-
};
|
|
168
|
-
});
|
|
169
|
-
</script>
|
|
170
|
-
|
|
171
|
-
<window bind:this={win}>
|
|
172
|
-
<!-- See the WidgetEventTypes interface for the names of all supported events. -->
|
|
173
|
-
<text
|
|
174
|
-
mouseTracking={true}
|
|
175
|
-
on:MouseMove={onMouseMove}
|
|
176
|
-
on:MouseButtonPress={onMouseButtonPress}
|
|
177
|
-
>
|
|
178
|
-
Move your mouse here
|
|
179
|
-
</text>
|
|
180
|
-
</window>
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
<img src="https://github.com/nodegui/react-nodegui/releases/download/assets/qevents.gif" alt="qevent example" style={{width: '100%', maxWidth: 400}}/>
|
|
184
|
-
|
|
185
|
-
Note here that every QEvent handler gives a reference to native QEvent in the handler callback.
|
|
186
|
-
Not all native QEvent wrappers are implemented yet and we might need your help regarding those. Feel free to jump in and contribute to the nodegui core.
|
|
187
|
-
|
|
188
|
-
Also you can specify the QEvent type as a regular `MouseMove` string or use it directly from the enum `WidgetEventTypes.MouseMove`. They both achieve same things.
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_label: Images
|
|
3
|
-
title: Images
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Images are very important for making your app more interesting.
|
|
7
|
-
|
|
8
|
-
In Svelte NodeGui, `<image>` is used to display an image.
|
|
9
|
-
|
|
10
|
-
Internally Image is a QLabel. QLabel is typically used for displaying text, but it can also display an image.
|
|
11
|
-
What this means is that you can pass all the props you pass to a `<text>` to `<image>` also.
|
|
12
|
-
|
|
13
|
-
A very minimal example would look like this:
|
|
14
|
-
|
|
15
|
-
```html
|
|
16
|
-
<script lang="ts">
|
|
17
|
-
import { onMount } from "svelte";
|
|
18
|
-
import { QLabelSignals, QMouseEvent, WidgetEventTypes } from "@nodegui/nodegui";
|
|
19
|
-
let win;
|
|
20
|
-
|
|
21
|
-
onMount(() => {
|
|
22
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
23
|
-
win.nativeView.show();
|
|
24
|
-
return () => {
|
|
25
|
-
delete (window as any).win;
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<window bind:this={win}>
|
|
31
|
-
<image src="https://docs.nodegui.org/img/logo-circle.png" />
|
|
32
|
-
</window>
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Here,
|
|
36
|
-
|
|
37
|
-
- Image is a native QLabel component that sets the image as its pixmap.
|
|
38
|
-
|
|
39
|
-
The result would look like this:
|
|
40
|
-
|
|
41
|
-
<img src="https://github.com/nodegui/react-nodegui/releases/download/assets/images.png" alt="image example" style={{width: '100%', maxWidth: 400}}/>
|
|
42
|
-
|
|
43
|
-
## Some tips
|
|
44
|
-
|
|
45
|
-
### Showing large images
|
|
46
|
-
|
|
47
|
-
The above examples wont allow you to show a huge image without either cutting it off or making the widget huge.
|
|
48
|
-
|
|
49
|
-
In order to do that:
|
|
50
|
-
|
|
51
|
-
- You can create the image instance using `<image>`
|
|
52
|
-
- Set the image instance as a child to a `<scrollArea>`
|
|
53
|
-
|
|
54
|
-
### Animated images
|
|
55
|
-
|
|
56
|
-
In order to use animated images, instead of `<image>` use `<animatedImage>`
|
|
57
|
-
|
|
58
|
-
### Loading an image from a buffer
|
|
59
|
-
|
|
60
|
-
Lets say we want to load an image from a buffer. In this case we can't use the `src` prop since its only reserved for local file system path or urls.
|
|
61
|
-
|
|
62
|
-
In this case use the `buffer` prop.
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_label: Layout
|
|
3
|
-
title: Layout
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Svelte NodeGui uses a layout system to automatically arrange child components within a component to ensure that they make good use of the available space.
|
|
7
|
-
|
|
8
|
-
## Fixed Dimensions
|
|
9
|
-
|
|
10
|
-
A component's height and width determine its size on the screen. The simplest way to set the dimensions of a component is by adding a fixed width and height to style. Setting dimensions this way is common for components that should always render at exactly the same size, regardless of screen dimensions.
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
import { onMount } from "svelte";
|
|
15
|
-
|
|
16
|
-
onMount(() => {
|
|
17
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
18
|
-
win.nativeView.show();
|
|
19
|
-
return () => {
|
|
20
|
-
delete (window as any).win;
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<window bind:this={win}>
|
|
26
|
-
<view style="width: 50px; height: 30px; background-color: yellow;"/>
|
|
27
|
-
</window>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Dynamic Layouts
|
|
32
|
-
|
|
33
|
-
Dynamic layouts automatically position and resize components when the amount of space available for them changes, ensuring that they are consistently arranged and that the user interface as a whole remains usable.
|
|
34
|
-
|
|
35
|
-
Svelte NodeGui currently supports layouting using FlexLayout.
|
|
36
|
-
|
|
37
|
-
## FlexLayout
|
|
38
|
-
|
|
39
|
-
FlexLayout allows the children to expand and shrink dynamically based on available space. Normally you will use `flex: 1`, which tells a component to fill all available space, shared evenly amongst other components with the same parent. The larger the flex given, the higher the ratio of space a component will take compared to its siblings.
|
|
40
|
-
|
|
41
|
-
> A component can only expand to fill available space if its parent has dimensions greater than 0. If a parent does not have either a fixed width and height or flex, the parent will have dimensions of 0 and the flex children will not be visible.
|
|
42
|
-
|
|
43
|
-
Flexbox is designed to provide a consistent layout on different screen sizes. You will normally use a combination of flex-direction, align-items,and justify-content to achieve the right layout.
|
|
44
|
-
|
|
45
|
-
### Example:
|
|
46
|
-
|
|
47
|
-
Lets say you want to build a UI that has a parent view which has two child components. One a label with text Hello and another a view with background color white. Now you want the label to occupy 1/3 of the available space while the white colored child view to occupy the remaining 2/3 space.
|
|
48
|
-
|
|
49
|
-
<img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/flex-layout-1.png" alt="flex layout example 1" style={{maxWidth: 700, width:'100%'}}/>
|
|
50
|
-
|
|
51
|
-
The code for that would look something like this:
|
|
52
|
-
|
|
53
|
-
```html
|
|
54
|
-
<script lang="ts">
|
|
55
|
-
import { onMount } from "svelte";
|
|
56
|
-
|
|
57
|
-
onMount(() => {
|
|
58
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
59
|
-
win.nativeView.show();
|
|
60
|
-
return () => {
|
|
61
|
-
delete (window as any).win;
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
</script>
|
|
65
|
-
|
|
66
|
-
<window bind:this={win}>
|
|
67
|
-
<view id="rootView">
|
|
68
|
-
<text id="label">Hello</text>
|
|
69
|
-
<view id="view"/>
|
|
70
|
-
</view>
|
|
71
|
-
</window>
|
|
72
|
-
|
|
73
|
-
<style>
|
|
74
|
-
#rootView{
|
|
75
|
-
height: '100%';
|
|
76
|
-
background-color: blue;
|
|
77
|
-
}
|
|
78
|
-
#label {
|
|
79
|
-
flex: 1;
|
|
80
|
-
color: white;
|
|
81
|
-
background-color: green;
|
|
82
|
-
}
|
|
83
|
-
#view {
|
|
84
|
-
flex: 3;
|
|
85
|
-
background-color: white;
|
|
86
|
-
}
|
|
87
|
-
</style>
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
> To know more on how FlexBox layout works in depth you can visit: https://facebook.github.io/react-native/docs/0.60/flexbox.
|
|
91
|
-
>
|
|
92
|
-
> NodeGui uses the same library that React Native uses underneath for FlexBox ([Yoga](https://github.com/facebook/yoga)).
|
|
93
|
-
|
|
94
|
-
- You can specify layout properties via inline styles also.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
## BoxView Layout
|
|
98
|
-
|
|
99
|
-
BoxView Layout is an implementation of QBoxLayout of NodeGui.
|
|
100
|
-
|
|
101
|
-
```html
|
|
102
|
-
<script lang="ts">
|
|
103
|
-
import { onMount } from "svelte";
|
|
104
|
-
import { Direction } from "@nodegui/nodegui";
|
|
105
|
-
import type { QPushButtonSignals } from "@nodegui/nodegui";
|
|
106
|
-
|
|
107
|
-
let additionalButtons: string[] = [];
|
|
108
|
-
let direction: Direction = Direction.LeftToRight;
|
|
109
|
-
|
|
110
|
-
function addHandler(): void {
|
|
111
|
-
additionalButtons = [...additionalButtons, `Button ${additionalButtons.length}`];
|
|
112
|
-
}
|
|
113
|
-
function removeHandler(): void {
|
|
114
|
-
additionalButtons = [...additionalButtons.slice(0, additionalButtons.length - 1)];
|
|
115
|
-
}
|
|
116
|
-
function toggleDirection(): void {
|
|
117
|
-
direction = ((direction + 1) % 4) as Direction;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
onMount(() => {
|
|
121
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
122
|
-
win.nativeView.show();
|
|
123
|
-
return () => {
|
|
124
|
-
delete (window as any).win;
|
|
125
|
-
};
|
|
126
|
-
});
|
|
127
|
-
</script>
|
|
128
|
-
|
|
129
|
-
<window bind:this={win}>
|
|
130
|
-
<boxView direction={direction}>
|
|
131
|
-
<button text="Add" on={addHandler} />
|
|
132
|
-
<button text="Remove" on={removeHandler} />
|
|
133
|
-
<button text="Toggle direction" on={toggleDirection} />
|
|
134
|
-
{#each additionalButtons as additionalButton (additionalButton)}
|
|
135
|
-
<button text={additionalButton}/>
|
|
136
|
-
{/each}
|
|
137
|
-
</boxView>
|
|
138
|
-
</window>
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
The above code produces
|
|
142
|
-
|
|
143
|
-
<img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/box-layout-1.png" alt="box layout example 1" style={{maxWidth: 700, width:'100%'}}/>
|
|
144
|
-
<img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/box-layout-2.png" alt="box layout example 1" style={{maxWidth: 700, width:'100%'}}/>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
## GridView Layout
|
|
148
|
-
|
|
149
|
-
GridView Layout is an implementation of QGridLayout of NodeGui.
|
|
150
|
-
|
|
151
|
-
```html
|
|
152
|
-
<script lang="ts">
|
|
153
|
-
import { onMount } from "svelte";
|
|
154
|
-
let win;
|
|
155
|
-
|
|
156
|
-
let additionalRows: string[] = [];
|
|
157
|
-
let additionalColumns: string[] = [];
|
|
158
|
-
let rowStretch: boolean = false;
|
|
159
|
-
|
|
160
|
-
function insertRowHandler(): void {
|
|
161
|
-
additionalRows = [...additionalRows, `Row ${additionalRows.length}`];
|
|
162
|
-
}
|
|
163
|
-
function removeRowHandler(): void {
|
|
164
|
-
additionalRows = [...additionalRows.slice(0, additionalRows.length - 1)];
|
|
165
|
-
}
|
|
166
|
-
function insertColumnHandler(): void {
|
|
167
|
-
additionalColumns = [...additionalColumns, `Column ${additionalColumns.length}`];
|
|
168
|
-
}
|
|
169
|
-
function removeColumnsHandler(): void {
|
|
170
|
-
additionalColumns = [...additionalColumns.slice(0, additionalColumns.length - 1)];
|
|
171
|
-
}
|
|
172
|
-
function toggleRowStretch(): void {
|
|
173
|
-
rowStretch = !rowStretch;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
onMount(() => {
|
|
177
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
178
|
-
win.nativeView.show();
|
|
179
|
-
return () => {
|
|
180
|
-
delete (window as any).win;
|
|
181
|
-
};
|
|
182
|
-
});
|
|
183
|
-
</script>
|
|
184
|
-
|
|
185
|
-
<window bind:this={win}>
|
|
186
|
-
<gridView
|
|
187
|
-
style="flex: 1"
|
|
188
|
-
columnProps={{
|
|
189
|
-
0: {
|
|
190
|
-
minWidth: 200,
|
|
191
|
-
},
|
|
192
|
-
1: {
|
|
193
|
-
minWidth: 300,
|
|
194
|
-
},
|
|
195
|
-
}}
|
|
196
|
-
rowProps={{
|
|
197
|
-
0: {
|
|
198
|
-
stretch: rowStretch ? 2 : undefined,
|
|
199
|
-
minHeight: 400,
|
|
200
|
-
},
|
|
201
|
-
1: {
|
|
202
|
-
stretch: !rowStretch ? 2 : undefined,
|
|
203
|
-
},
|
|
204
|
-
}}
|
|
205
|
-
>
|
|
206
|
-
<gridRow>
|
|
207
|
-
<gridColumn width={2}>
|
|
208
|
-
<view style="background-color: red">
|
|
209
|
-
<text>Hello</text>
|
|
210
|
-
<button text="Insert row" on:clicked={insertRowHandler} />
|
|
211
|
-
<button text="Remove row" on:clicked={removeRowHandler} />
|
|
212
|
-
<button text="Toggle row stretch" on:clicked={toggleRowStretch} />
|
|
213
|
-
<button text="Insert column" on:clicked={insertColumnHandler} />
|
|
214
|
-
<button text="Remove column" on:clicked={removeColumnsHandler} />
|
|
215
|
-
</view>
|
|
216
|
-
</gridColumn>
|
|
217
|
-
<gridColumn width={2}>
|
|
218
|
-
<view style="background-color: blue">
|
|
219
|
-
<text>Second Column</text>
|
|
220
|
-
</view>
|
|
221
|
-
</gridColumn>
|
|
222
|
-
{#each additionalColumns as column (column)}
|
|
223
|
-
<gridColumn>
|
|
224
|
-
<text>{column}</text>
|
|
225
|
-
</gridColumn>
|
|
226
|
-
{/each}
|
|
227
|
-
</gridRow>
|
|
228
|
-
<gridRow height={2}>
|
|
229
|
-
<gridColumn>
|
|
230
|
-
<view style="background-color: green">
|
|
231
|
-
<text>Second row</text>
|
|
232
|
-
</view>
|
|
233
|
-
</gridColumn>
|
|
234
|
-
<gridColumn>
|
|
235
|
-
<view style="background-color: purple">
|
|
236
|
-
<text>Second Column</text>
|
|
237
|
-
</view>
|
|
238
|
-
</gridColumn>
|
|
239
|
-
<gridColumn>
|
|
240
|
-
<view style="background-color: purple">
|
|
241
|
-
<text>Third Column</text>
|
|
242
|
-
</view>
|
|
243
|
-
</gridColumn>
|
|
244
|
-
<gridColumn>
|
|
245
|
-
<view style="background-color: purple">
|
|
246
|
-
<text>Fourth Column</text>
|
|
247
|
-
</view>
|
|
248
|
-
</gridColumn>
|
|
249
|
-
{#each additionalColumns as column (column)}
|
|
250
|
-
<gridColumn>
|
|
251
|
-
<text>Second {column}</text>
|
|
252
|
-
</gridColumn>
|
|
253
|
-
{/each}
|
|
254
|
-
</gridRow>
|
|
255
|
-
<gridRow>
|
|
256
|
-
<gridColumn>
|
|
257
|
-
<text>Third row</text>
|
|
258
|
-
</gridColumn>
|
|
259
|
-
</gridRow>
|
|
260
|
-
{#each additionalRows as row (row)}
|
|
261
|
-
<gridColumn>
|
|
262
|
-
<gridColumn width={2}>
|
|
263
|
-
<text>{row}</text>
|
|
264
|
-
</gridColumn>
|
|
265
|
-
<gridColumn>
|
|
266
|
-
<text>Second {row}</text>
|
|
267
|
-
</gridColumn>
|
|
268
|
-
</gridColumn>
|
|
269
|
-
{/each}
|
|
270
|
-
</gridView>
|
|
271
|
-
</window>
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
The above code produces
|
|
275
|
-
|
|
276
|
-
<img src="https://github.com/nodegui/react-nodegui/raw/gh-pages/img/grid-layout-1.png" alt="grid layout example 1" style={{maxWidth: 700, width:'100%'}}/>
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
## Conclusion
|
|
280
|
-
|
|
281
|
-
The primary layout in Svelte NodeGui is the Flexbox layout. Flexbox layout can be controlled via stylesheet just as in web. So both paint and layout properties are available at the same place.
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_label: Networking
|
|
3
|
-
title: Networking
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Many apps need to load resources from a remote URL. You may want to make a POST request to a REST API, or you may need to fetch a chunk of static content from another server.
|
|
7
|
-
|
|
8
|
-
Remember that NodeGui apps do not run in a browser and hence do not have access to browser apis. NodeGui app is essentially a Node.js app.
|
|
9
|
-
|
|
10
|
-
And in a typical Node.js application you would use a third party library like [axios](https://github.com/axios/axios), [node-fetch](https://github.com/node-fetch/node-fetch) or [frisbee](https://github.com/niftylettuce/frisbee) for achieving this functionality.
|
|
11
|
-
|
|
12
|
-
## Using Node Fetch
|
|
13
|
-
|
|
14
|
-
[Node Fetch](https://github.com/node-fetch/node-fetch) is a light-weight module that brings window.fetch to Node.js.
|
|
15
|
-
|
|
16
|
-
An example usage would look like this:
|
|
17
|
-
|
|
18
|
-
```js
|
|
19
|
-
const fetch = require("node-fetch");
|
|
20
|
-
async function getData() {
|
|
21
|
-
try {
|
|
22
|
-
let response = await fetch("https://somewebsite.com/some.json");
|
|
23
|
-
let responseJson = await response.json();
|
|
24
|
-
return responseJson.somecontent;
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error(error);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Take a look at the [Node Fetch docs](https://github.com/node-fetch/node-fetch) for a full list of properties.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_label: Packaging
|
|
3
|
-
title: Packaging
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
In order to distribute your finished app, you can use [@nodegui/packer](https://github.com/nodegui/packer)
|
|
7
|
-
|
|
8
|
-
- **Step 1: (Run this command only once)**
|
|
9
|
-
|
|
10
|
-
```sh
|
|
11
|
-
npx nodegui-packer --init MyAppName
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
This will produce the deploy directory containing the template. You can modify this to suite your needs. Like add icons, change the name, description and add other native features or dependencies. Make sure you commit this directory.
|
|
15
|
-
|
|
16
|
-
- **Step 2: (Run this command every time you want to build a new distributable)**
|
|
17
|
-
|
|
18
|
-
Next you can run the pack command:
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
npm run build
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
This will produce the js bundle along with assets inside the ./dist directory
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
npx nodegui-packer --pack ./dist
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
This will build the distributable using @nodegui/packer based on your template. The output of the command is found under the build directory. You should gitignore the build directory.
|
|
31
|
-
|
|
32
|
-
More details about packer can be found here: https://github.com/nodegui/packer
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_label: ScrollArea
|
|
3
|
-
title: Scroll Area
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
ScrollArea allows you to display a large content (image, list or even plain text) in an area of predefined size. A scroll area is used to display the contents of a child widget within a frame. If the widget exceeds the size of the frame, the view can provide scroll bars so that the entire area of the child widget can be viewed.
|
|
7
|
-
|
|
8
|
-
## Example
|
|
9
|
-
|
|
10
|
-
```html
|
|
11
|
-
<script lang="ts">
|
|
12
|
-
import { onMount } from "svelte";
|
|
13
|
-
|
|
14
|
-
onMount(() => {
|
|
15
|
-
(window as any).win = win; // Prevent garbage collection.
|
|
16
|
-
win.nativeView.show();
|
|
17
|
-
return () => {
|
|
18
|
-
delete (window as any).win;
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<window bind:this={win}>
|
|
24
|
-
<scrollArea>
|
|
25
|
-
<text>
|
|
26
|
-
Contrary to popular belief,
|
|
27
|
-
Lorem Ipsum is not simply random text.
|
|
28
|
-
It has roots in a piece of classical Latin literature from 45 BC,
|
|
29
|
-
making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia,
|
|
30
|
-
looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage,
|
|
31
|
-
and going through the cites of the word in classical literature,
|
|
32
|
-
discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32
|
|
33
|
-
and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC.
|
|
34
|
-
This book is a treatise on the theory of ethics, very popular during the Renaissance.
|
|
35
|
-
The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
|
|
36
|
-
|
|
37
|
-
The standard chunk of Lorem Ipsum used since the 1500s
|
|
38
|
-
is reproduced below for those interested.
|
|
39
|
-
Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also
|
|
40
|
-
reproduced in their exact original form, accompanied
|
|
41
|
-
by English versions from the 1914 translation by H. Rackham.
|
|
42
|
-
|
|
43
|
-
Why do we use it?
|
|
44
|
-
|
|
45
|
-
It is a long established
|
|
46
|
-
fact that a reader will be distracted by
|
|
47
|
-
the readable content of a page when looking at its layout.
|
|
48
|
-
The point of using Lorem Ipsum is that it has
|
|
49
|
-
a more-or-less normal distribution of letters,
|
|
50
|
-
as opposed to using 'Content here, content here',
|
|
51
|
-
making it look like readable English.
|
|
52
|
-
Many desktop publishing packages and web page
|
|
53
|
-
editors now use Lorem Ipsum as their default model text,
|
|
54
|
-
and a search for 'lorem ipsum' will uncover many web
|
|
55
|
-
sites still in their infancy. Various versions
|
|
56
|
-
have evolved over the years, sometimes by accident,
|
|
57
|
-
sometimes on purpose (injected humour and the like).
|
|
58
|
-
</text>
|
|
59
|
-
</scrollArea>
|
|
60
|
-
</window>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**TLDR;**
|
|
64
|
-
|
|
65
|
-
We create a `<scrollArea>` instance and then set the target widget as its child.
|
|
66
|
-
|
|
67
|
-
The result would look like this:
|
|
68
|
-
|
|
69
|
-
<img src="https://github.com/nodegui/react-nodegui/releases/download/assets/scrollarea.gif" alt="scroll area" style={{width: '100%', maxWidth: 400}}/>
|