Skip to content

Commit 464d52a

Browse files
committed
Fixed documentation.
1 parent c8479dd commit 464d52a

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

docs/reference/window.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ int main()
1515
Nui::Window wnd1{};
1616
std::unique_ptr<Nui::Window> wnd2{};
1717

18-
wnd.bind("myFunction", [&wnd2](nlohmann::json const&) {
19-
wnd2 = std::make_unique<Nui::Window>();
20-
wnd2->setSize(800, 600);
21-
wnd2->setHtml("<html><body><h1>Hello World!</h1></body></html>");
18+
wnd.bind("myFunction", [&wnd2, &wnd1](nlohmann::json const&) {
19+
// required on windows to spawn the second window not from within this thread:
20+
wnd1.dispatch([](){
21+
wnd2 = std::make_unique<Nui::Window>();
22+
wnd2->setSize(800, 600);
23+
wnd2->setHtml("<html><body><h1>Hello World!</h1></body></html>");
24+
});
2225
});
2326

2427
wnd.run();

docs/tutorials/rpc.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ All are disabled by default for security reasons.
3636

3737
### Usage
3838

39-
#### Backend
39+
#### Backend
4040
Registering a function that is callable from the frontend:
4141
```cpp
4242
#include <nui/backend/rpc_hub.hpp>
@@ -56,7 +56,7 @@ int main()
5656

5757
// highlight-start
5858
hub.registerFunction(
59-
"functionName",
59+
"functionName",
6060
// Parameters can either be be converted from json by nlohmann::json.get<decay_t<T>>...
6161
[&hub](std::string const& responseId, int param2){
6262
// ...
@@ -65,7 +65,7 @@ int main()
6565
);
6666

6767
hub.registerFunction(
68-
"functionName",
68+
"functionName",
6969
// ...or a nlohmann::json and you can dissect it yourself:
7070
[](nlohmann::json const& args){
7171
// ...
@@ -118,7 +118,7 @@ void foo()
118118

119119
// Useful RAII unregister (also available in backend):
120120
{
121-
auto unregisterWhenThisFallsOutOfScope =
121+
auto unregisterWhenThisFallsOutOfScope =
122122
Nui::RpcClient::autoRegisterFunction("asdf", [](){});
123123
} // asdf no longer exists here.
124124

@@ -165,7 +165,7 @@ void foo()
165165

166166
Example:
167167
```cpp
168-
#include <nui/filesystem/file_dialog.hpp>
168+
#include <nui/frontend/filesystem/file_dialog.hpp>
169169

170170
void foo()
171171
{
@@ -287,7 +287,7 @@ Nui::ThrottledFunction throttled;
287287
288288
void foo() {
289289
throttle(
290-
200 /*ms*/,
290+
200 /*ms*/,
291291
[](){
292292
std::cout << "Not printed faster than 200ms after the last call.";
293293
},
@@ -319,7 +319,7 @@ Nui::TimerHandle timer;
319319
void foo()
320320
{
321321
Nui::setInterval(
322-
500 /*ms*/,
322+
500 /*ms*/,
323323
// Called every 500ms
324324
[](){std::cout << "Hello!\n";},
325325
[&timer](Nui::TimerHandle&& t){

0 commit comments

Comments
 (0)