How to use ResizerWidget in Dlangui app..?

ShadoLight ettienne.gilbert at gmail.com
Mon Dec 30 23:32:37 UTC 2019


Hi,

I suspect I'm missing something obvious, but ResizerWidget is not 
working for me on Windows - it shows the 'dragging'-cursor when 
hovering the mouse on the ResizerWidget, but dragging with the 
left mouse button does nothing.

Reduced very simple example:

///app.d
import dlangui;
import gui;

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", null);

     //Make main layout
     auto mainGui = new GuiHandler();
     window.mainWidget = mainGui.makeGui(window);
     // show window
     window.show();

     // run message loop
     return Platform.instance.enterMessageLoop();
}

/// gui.d
import dlangui;

class GuiHandler : ResizeHandler {

	Widget makeGui(Window w) {
		//Make main layout
		auto vlayout = new VerticalLayout();
		vlayout.margins = 20;
		vlayout.padding = 10;ets
		vlayout.backgroundColor = 0xFFFFC0;
		vlayout.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);

		// Layout for editors
		auto editorsLayout = new LinearLayout();
		editorsLayout.orientation = Orientation.Vertical;
		
		//Make edit + trace windows
		auto editor = new EditBox();
		editorsLayout.addChild(editor);
		
		auto resizer = new ResizerWidget();
//		resizer.resizeEvent.connect(this); //Connect for handling 
events in onResize.
		editorsLayout.addChild(resizer);
		
		auto tracer = new LogWidget();
		editorsLayout.addChild(tracer);
		
		editorsLayout.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
		vlayout.addChild(editorsLayout);
	
		return vlayout;
	}
	
	override void onResize(ResizerWidget source, ResizerEventType 
event, int currentPosition) {
              //Not shown...
	}
}

I searched through all the dlangui examples where ResizerWidget 
is used, and none of them provides any onResize event handler as 
shown above. But, since none of them work (symptoms exactly the 
same as mine), I am wondering if this is required?

Also checking in DlanguiIDE - nowhere does it implements the 
onResize event handler for ResizerWidget either. I find this a 
bit odd - in none of the projects where ResizerWidget are used 
does it work, but none of these projects provide the onResize 
event handler either.  Which makes me suspect it is supposed to 
work 'out of the box' and does not require the event handler for 
the basic dragging functionality - similar how resizing the whole 
window works without requiring that you implement it yourself in 
the OnResize event handler for the main Widget. Also - I can 
hardly believe that Vadim would have kept putting it in examples, 
but without it working, so I suspect some regression here if I am 
not doing something stupid myself (which is always possible!).

There are plenty of 'deprecated' warnings when building dlangui 
and, since dlangui has not been updated since 2018, I'm concerned 
it may be breaking with new versions of the compiler.

Alternatively I'm missing something elementary here..? Has anyone 
used ResizerWidget successfully with a recent version of the 
compiler on Windows?

win 7
DMD32 D Compiler v2.089.1
dlangui-0.9.182



More information about the Digitalmars-d-learn mailing list