StartupActions: maximise browser window based on screen width?

96 views
Skip to first unread message

Hubert

unread,
Jun 27, 2018, 6:27:07 AM6/27/18
to TiddlyWiki
Hi,

I'm trying to make use of the new StartupActions functionality.

I'm using TW on multiple computers with different screen sizes and what I'm trying to do is maximise the browser window on startup IF the current screen width ($:/info/browser/screen/width) matches 1366 pixels (laptop).

I've created a tiddler named StartUp and tagged it with $:/tags/StartupAction/Browser

In the tiddler's text area, I've typed in the following code (the dependency here is Evan Balster's formula macro):

\define BlaBla()
<$set name=screen_width value={{$:/info/browser/screen/width}}>
<<Conditionals>>
</$set>
\end

\define Conditionals()
<$formula formula="if(($(screen_width)$=1366), '<<MaximiseBrowserWindow>>', '')"/
>
\end

\define MaximiseBrowserWindow()
<$action-sendmessage $message="tm-full-screen"/>
\end

<<BlaBla>>

Unfortunately this does nothing.

For testing purposes, I've removed most of the above code and left out just the action line:

<$action-sendmessage $message="tm-full-screen"/>

This does nothing either.

I know it is strange just to place actions in tiddlers on their own but I would have assumed that the trigger here is startup itself and the code should be executed just because the tiddler is tagged as it should, as if the whole snippet was a button action (?)

Is there anything I'm missing here or is it just that, by design, actions cannot be executed conditionally?

Thank you for your input.


admls

unread,
Mar 6, 2019, 5:47:26 PM3/6/19
to TiddlyWiki
Hi Hubert,

Just wanted to see if you ever got this to work. I'm running into a similar problem at the moment with StartupActions. I could use a bit of insight into its workings.

Best wishes,

Adam

Hubert

unread,
Mar 7, 2019, 3:54:15 AM3/7/19
to TiddlyWiki
Hi Adam,

I've been successfully using startup actions to manipulate variables, set fields, create tiddlers etc. but the one thing I still could not get it to action are widget messages, like tm-full-screen. I'm not quite sure why.

For the record, the above code could be simplified to this. It still doesn't work, probably because the widget message can only be dispatched using a button widget as the trigger, unlike regular actions (it's just my assumption as I failed to get a satisfactory explanation).

<$reveal state="$:/info/browser/screen/width!!text" type="match" text="1366">
<$action-sendmessage $message="tm-full-screen" param="enter"/>
</$reveal>

Sorry I wasn't able to help.
Good luck!

-Hubert

Andreas Hahn

unread,
Mar 7, 2019, 4:06:01 AM3/7/19
to tiddl...@googlegroups.com
Hi Adam,

unfortunately, the simple answer to this is: `tm-full-screen` will never
work as a startup action, as these actions run before the rootwidget is
initialized to listen for and handle these messages.

It could work if you figure out a way to delay the action, but I'm not
sure how one would go about that.

/Andreas

Jeremy Ruston

unread,
Mar 7, 2019, 4:15:45 AM3/7/19
to tiddl...@googlegroups.com
I believe that the problem here is browser security: they think nobody would want a website that fullscreens itself without permission when it opens, and so they implement a restriction whereby fullscreen can only be entered within a user-triggered event handler (e.g. a button).

Best wishes

Jeremy.


--
Jeremy Ruston
jer...@jermolene.com
https://jermolene.com
> --
> You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
> To post to this group, send email to tiddl...@googlegroups.com.
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/44ca7e9c-d560-7290-8bda-151901524fd2%40googlemail.com.
> For more options, visit https://groups.google.com/d/optout.

admls

unread,
Mar 11, 2019, 6:16:05 PM3/11/19
to TiddlyWiki
Thanks for the feedback everybody!
Reply all
Reply to author
Forward
0 new messages