The right-click menu conflict should only be with TiddlyWiki’s own right-click events. There shouldn’t be any other conflicting events, right? I can’t think of any other cases that would use the right-click menu. Can you give examples of other use cases?
This can’t be implemented for now, as it may cause some other logical issues. As for alternative temporary solutions, I might add them later.
I tested it briefly, and everything seems okay. I’m not sure what problem you mean by “can’t load.”
Try this instead: TiddlyTools/Modules/Info/WindowSize.js
Instead of using a “startup” module to directly create/update the $:/info/browser/window/width
and $:/info/browser/window/height
tiddlers, this newer code uses a TWCore “info” module to get and track the window size values.
Let me know if it works any better for you.
-e
Actually the code given in this post is working - Would it be a good idea to implement in TW to update the infomechanism when entering/leaving fullscreen? - #2 by EricShulman
Error in the tiddlywiki-app occurred when I used the code given in the TiddlyTools site - TiddlyTools for TW v5.3.6 — Small Tools for Big Ideas!™. But this code worked in my browser.
I thought both codes were the same and took the one from TiddlyTools site thinking that it might be a updated version. Sorry for the confusion guys.
@EricShulman any particular reason why one code shows error while the other doesn’t. It would be better to give both code in TiddlyTools website since both have separate usecases
I guess this was due to some issues with my modifier keys and mac keyboard or bluetooth keyboard. When ever I use ctrl
as the modifier key the right click menu pop ups. As a temporary solution, I am changing the ctrl
modifier key to something else
The “window size” info add-on uses the following code logic:
if (!$tw.browser) return([]);
var w=( window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth );
var h=( window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight );
Note how it first checks to ensure that it is running in a browser environment (where $tw.browser
has a value). If the tiddlywiki-app doesn’t pass this check, then the code simply returns an empty array and the $:/info/browser/window/width
and $:/info/browser/window/height
tiddlers are not created.
Next, the code uses values contained in objects that are defined by the browser itself (window
OR document.documentElement
OR document.body
) to fetch the current window width and height values. The different object references are there to handle different browser-specific implementations, where window.innerWidth
and window.innerHeight
are the most common standard, and document.documentElement
and document.body
are there as “fallback” values for older browsers.
If none of these browser-specific objects exist in the tiddlywiki-app environment, then w
and h
will be undefined, and the subsequent w.toString()
and h.toString()
calls that set the $:/info
tiddler values will fail and throw an uncaught error: “Cannot read properties of null (reading ‘toString’)`”.
To address this, I’ve added a new check in the TiddlyTools/Modules/Info/WindowSize.js
code so that the $:/info
tiddlers will not be created in this case:
if (!w || !h) return([]);
Of course, this doesn’t really solve your issue, since you will still want to have useful window width/height values, even when running within the tiddlywiki-app. To make that work, I suggest that the tiddlywiki-app should ensure that it defines valid window.innerWidth
and window.innerHeight
object attributes that my code can then use properly.
-e
Code given in this above given post was working in my wiki loaded in tiddlywiki-app.
@oeyoews I think you should give a different name to your app. Something other than tiddlywiki-app. The current name can cause confusion sometimes
Since the old startup
module code does return valid width/height values, it suggests that there may be a problem in the tiddlywiki-app handling for the $:/info
module mechanism.
-e
Follow-up:
The old startup
module code works for the tiddlywiki-app because it doesn’t check for $tw.browser
but still has window.innerWidth
and window.innerHeight
defined so it can return valid values.
I have just updated the newer info
module code to use a try/catch
wrapper instead of checking for $tw.browser
. This should allow it to work for the tiddlywiki-app, while suppressing RSOD errors that may occur in other non-browser environments.
Please try removing the old startup
module code and use the latest update from here: TiddlyTools/Modules/Info/WindowSize.js
Let me know if it works or not.
-e
I got the same error after drag dropping the windowsize js tiddler and reloading the wiki
I should have asked this previously… EXACTLY what error is being reported?
This was the error
It seems that this code lacks the judgment of $tw.browser. For nodejs, it will first run once in the nodejs environment, and naturally report an error.
I’ve expanded the try/catch wrapper around the entire getWindowSize
AND window.addEventListener
code. This should prevent any fatal errors from being reported.
Get the latest update here:
TiddlyTools/Modules/Info/WindowSize.js
Give it a try and let me know if:
A) the startup error is avoided
B) the $:/info/browser/window/width
and $:/info/browser/window/height
shadow tiddlers are correctly initialized
C) the “resize” event listener is established so the $:/info/...
tiddlers are updated when the window is resized
-e
I tested and these are the findings
- startup error is fixed now
-
$:/info/browser/window/width
and$:/info/browser/window/height
tiddlers are initialized correctly. - but
$:/info/browser/window/width
and$:/info/browser/window/height
tiddlers are not updated when the window is resized
The old “startup” code and the newer “info” code both use the same window.addEventListener("resize",...)
method to trigger updates to the tiddler values when the window is resized. Are you saying that the old “startup” code handles window resizing, but the newer “info” code does not???
-e
The info tiddlers were not getting updated on realtime when I resized the window
As currently written, TiddlyTools/Modules/Info/WindowSize.js expects there to be a global window
object that receives a “resize” event in order to trigger automatic updates to the values stored in the $:/info/...
tiddlers.
This suggests that the tiddlywiki-app is not using a “listener” to handle window resize
events… or perhaps the tiddlywiki-app containing object is not a window
or is getting a different event other than “resize”.
@oeyoews, can you check on this and let me know if there is something else I can write for compatibility with the tiddlywiki-app environment?
-e
I am confident these have something to do with my prior “review”;