MoI discussion forum
MoI discussion forum

Full Version: Font size of Alert box

From: bemfarmer
16 Oct   [#1]
Is it possible to change the font size of text in the Alert box created, or used, by a script? (javascript?)
Or change the color?
Does Moi just use the javascript alert box? Or is there a programmed alert box?

Internet search mostly said NO.
There was some talk about making an alternative alert box, or using CSS...

- Brian
From: Michael Gibson
16 Oct   [#2] In reply to [#1]
Hi Brian,

re:
> Is it possible to change the font size of text in the Alert box created, or
> used, by a script? (javascript?)
> Or change the color?

Sorry no there isn't a way to modify the appearance of moi.ui.alert().

But you can make your own dialog instead.


> Does Moi just use the javascript alert box? Or is there a programmed alert box

moi.ui.alert() uses the Qt message box dialog.

For making your own custom one here is an example to get you started.
Put this into a file MyAlert.htm inside of the appdata commands folder:

code:
<html>
	<head>
		<title>Window title</title>

		<style>
			#text_container {
				padding-top:0.2em;
				min-width:15em;
				font-size:110%;
			}

			#buttons_container {
				text-align:right;
				white-space:nowrap;
				margin-top:0.7em;
			}

		</style>
	</head>

	<body class="DialogBody">
		<div id="text_container">
		</div>

		<div id="buttons_container">
			<moi:DialogOK/>
		</div>

		<script>
			if ( g_Text )
				text_container.innerText = g_Text;
		</script>
	</body>
</html>


Then when you want to show it, do this:

code:
var dlg = moi.ui.createDialog( 'moi://commands/MyAlert.htm' );
dlg.htmlWindow.g_Text = 'Text of alert';
dlg.window.doModal();


You should get this:



- Michael

Image Attachments:
custom_alert_example.png 


From: bemfarmer
16 Oct   [#3] In reply to [#2]
Thank you Michael

With my Windows set to the high resolution (4k-ish), and current monitor, there is too much eye strain for numerous programs, not just MOI. So I should get a larger monitor.

Using a larger font for the Alert box is probably going in the wrong direction? The LogSpiral8 script is used as an example.
In the upper right corner, a blue question mark will pop up an overly large Alert box, with written documentation. Perhaps melding the blue question mark, with the blue flask technique, might be good.
The blue question mark would be set up to link to a more extensive documentation page, for that particular script. The documentation could be similar to the API ref, or have more graphics? The format would be... ?

- Brian
From: Michael Gibson
16 Oct   [#4] In reply to [#3]
Hi Brian,

re:
> there is too much eye strain for numerous programs, not just MOI. So I should get a larger monitor.

Is the rest of the MOI UI ok for you by increasing Options > UI size?

I'lll see if I can adjust moi.ui.alert() to use that as well.


> The format would be... ?

Well, either HTML or PDF are good since they're cross platform.

If you call moi.filesystem.shellExecute( 'path_to_docs.htm' ); then that will display the doc file in the system's web browser or PDF viewer.

- Michael
From: bemfarmer
18 Oct   [#5] In reply to [#4]
Thank you Michael.

I bumped Options > UI size from 10 to 11, which is helpful.
The Alert box size does not seem to change.

- Brian
From: Michael Gibson
18 Oct   [#6] In reply to [#5]
Hi Brian, I've got a fix for the next beta so the alert box will use the UI font size.

- Michael
From: bemfarmer
18 Oct   [#7] In reply to [#6]
That is great news!
Thank you Michael.

- Brian