Comments (3)
Here is the full code:
import dlangui;
import std;
mixin APP_ENTRY_POINT;
/// entry point for dlangui based application
extern (C) int UIAppMain(string[] args) {
// create window
Window window = Platform.instance.createWindow("DlangUI example - HelloWorld", null);
// frames
auto frame1 = new AppFrame();
auto frame2 = new AppFrame();
/****** FRAME 1 ********/
auto frame1_button1 = new Button(null, "Press me"d);
auto frame1_button2 = new Button(null, "Remove me"d);
auto frame1_button3 = new Button(null, "new window frame"d);
frame1.addChildren([
new HorizontalLayout().addChildren([
new TextWidget(null, "1 text item"d),
new TextWidget(null, "2 text item"d),
new TextWidget(null, "3 text item"d)
]),
new TextWidget(null, "4 text item"d),
new TextWidget(null, "5 text item"d),
new TextWidget(null, "6 text item"d),
frame1_button1,
frame1_button2,
frame1_button3,
]);
frame1_button1.click = delegate(Widget src) {
frame1.addChild(new TextWidget(null, "hello, world! "d ~ frame1.childCount.to!dstring));
return true;
};
frame1_button2.click = delegate(Widget src) {
frame1.removeChild(frame1.childCount-1);
return true;
};
frame1_button3.click = delegate(Widget src) {
window.executeInUiThread(() => window.mainWidget = frame2);
return true;
};
/****** FRAME 2 ********/
auto frame2_button1 = new Button(null, "Take me back"d);
frame2.addChildren([
new TextWidget(null, "4 text item"d),
new TextWidget(null, "5 text item"d),
frame2_button1,
]);
frame2_button1.click = delegate(Widget src) {
window.executeInUiThread(() => window.mainWidget = frame1);
return true;
};
// start with frame 1
window.executeInUiThread(() => window.mainWidget = frame1);
// show window
window.show();
// run message loop
return Platform.instance.enterMessageLoop();
}
from dlangui.
Thanks, I'll take a look when I get time!
from dlangui.
Here is the full code:
So the reason why this happens is:
@property void mainWidget(Widget widget)
{
mainWidgetChange(this, _mainWidget, widget);
if (_mainWidget !is null)
{
_mainWidget.window = null;
destroy(_mainWidget); // This line
}
_mainWidget = widget;
if (_mainWidget !is null)
_mainWidget.window = this;
}
When you change the widget, the "source" widget gets destroyed, so when you attempt to set it the second time it errors out.
I cannot simply remove this behavior as it will break other parts of dlangui. For now, the workaround would be creating the frame from scratch.
from dlangui.
Related Issues (20)
- [Linux example1] OpenGL tab seems to grey out the UI HOT 9
- Icons are broken on linux HOT 4
- How to open URL with UrlImageTextButton widget? HOT 4
- How to load font from resources? HOT 11
- Why ARGB and not RGBA? HOT 5
- How to set widget width in pixels? HOT 6
- bug: AppFrame veritical scrollbar scrolls mainMenu, toolbar, statusbar. Wheel not work HOT 1
- Drag & Drop doesn't work when ran as admin on Windows HOT 1
- `GridWidgetBase` should use `ulong` for measuring counts
- `GridWidgetBase` should use `UIString` instead of `dstring`
- How to change cursor type? HOT 2
- Can not load freetype library HOT 2
- Question about CSS HOT 4
- Missing Images? HOT 3
- DMLEdit crashes on resizing things
- Hi Grim HOT 3
- Fix for the broken renameTab(...) in tabs.d
- Invalidating a widget doesn't cause a redraw
- Getting an OpenGL widget to work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dlangui.