Dialog initially without scrollbar

Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Dialog initially without scrollbar

Post by Patrik » Wed Feb 03, 2021 7:18 pm

Hi,

I have a dialog that contains a lot of content so it should have a scrollbar. But initially there is no scrollbar. When I resize the dialog (explicitly or by resizing the browser window) the scrollbar appears. Also when I perform the action again (the dialog is a member).

Hier is the code of my minimized sample:

Code: Select all

DialogTestAction = function (editor) {
	sync.actions.AbstractAction.call(this, '');
	this.editor = editor;
	this.dialog = workspace.createDialog();
};

DialogTestAction.prototype = Object.create(sync.actions.AbstractAction.prototype);
DialogTestAction.prototype.constructor = DialogTestAction;

DialogTestAction.prototype.getDisplayName = function () {
	return 'Dialog-Test';
};

DialogTestAction.prototype.actionPerformed = function (callback) {
	this.dialog.setTitle('Ergebnis');
	this.dialog.getElement().innerHTML = '<p style="min-width: 200px">';
	for (i = 0; i < 30; i++) {
		this.dialog.getElement().innerHTML += 'Test Test Test<br/>';
  	}
	this.dialog.getElement().innerHTML += '</p>';
	this.dialog.show();
	this.dialog.focus();
};
My workaround is to make the dialog resizable so the user can reszie it and let the scrollbar appear. But I'd prefer the scroll bar to be thare right at the beginning. Any suggestions how to achieve that?

Thanks and regards,
Patrik

mihai_coanda
Posts: 37
Joined: Wed Jul 20, 2016 8:22 am

Re: Dialog initially without scrollbar

Post by mihai_coanda » Thu Feb 04, 2021 3:13 pm

Hello Patrik,

Thank you for reporting this issue. I have added an internal issue on it.
To work around this issue you could set the dialog's preferred size using the following code snippet:

Code: Select all

this.dialog.setPreferredSize(300, 500);
to any values you desire.

Regards,
Michael
Michael
http://www.oxygenxml.com

Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Dialog initially without scrollbar

Post by Patrik » Thu Feb 04, 2021 8:35 pm

Hi Michael,

thanks for the workaround - although it is not realy working for me since the content is generated dynamically and I can hardly guess any reasonable preferred size. But makingit resizable to the user can "activate" the scrollbar manually will work for now.

Regards,
Patrik

mihai_coanda
Posts: 37
Joined: Wed Jul 20, 2016 8:22 am

Re: Dialog initially without scrollbar

Post by mihai_coanda » Fri Feb 05, 2021 9:41 am

Hi Patrik

As you cannot determine a suitable dialog height you could set a very large height that would force the dialog size recalculation to fit the screen:

Code: Select all

  this.dialog.setPreferredSize(null, 50000);
This would also enable the dynamic width of the dialog to better fit the content.

Regards,
Michael.
Michael
http://www.oxygenxml.com

Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Dialog initially without scrollbar

Post by Patrik » Fri Feb 05, 2021 10:17 am

Hi Michael,

thanks, but the content might also be only a single line - which looks very strange on a full-screen-dialog... ;)

But I implemented a simple algorithm to guess if the content is large, and set the preferred hight to null or 10000 depending on that. This works fine!

Regards,
Patrik

mihai_coanda
Posts: 37
Joined: Wed Jul 20, 2016 8:22 am

Re: Dialog initially without scrollbar

Post by mihai_coanda » Fri Feb 05, 2021 10:46 am

Hi Patrick,

Glad that you found a solution that best suits your needs.

I will update this thread once the issue is fixed.

Regards,
Michael
Michael
http://www.oxygenxml.com

Post Reply