Page MenuHomeFeedback Tracker

Expand onHTMLLink event handler
Feedback, WishlistPublic

Description

Please make onHTMLLink fire when clicking on links to sections. Currently it only fires when clicking an external link.

Details

Legacy ID
2655333559
Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
Feature Request

Event Timeline

Mikeeeyy set Category to Feature Request.Feb 16 2016, 5:02 AM
Mikeeeyy set Reproducibility to N/A.
Mikeeeyy set Severity to None.
Mikeeeyy set Resolution to Open.
Mikeeeyy set Legacy ID to 2655333559.May 8 2016, 1:44 PM

I would appreciate this too, having the event fire even when the link is not valid would be perfect for triggering other scripted events from custom dialog or htmlLoad.

If the link is invalid it could be ignored, by default, or the event handler could be changed to expect a boolean return to prevent/allow the url opening - in the same way that "InventoryOpened" can be blocked with a {true}

Example:

"You can <a href='doExtraCommand'>click here</a> to perform a scripted action"

//Link check
_testCtrl ctrlAddEventHandler ["HTMLLink", {
	params ["_ctrl", "_link"];
	if (_link == "doExtraCommand") then {
		[] spawn {
			systemChat "Running extra command...";
			...
		};
	};
}];

//Event handler boolean return
_testCtrl ctrlAddEventHandler ["HTMLLink", {
	params ["_ctrl", "_link"];
	if (_link == "doExtraCommand") then {
		[] spawn {
			systemChat "Running extra command...";
			...
		};
		//Prevent the link from opening
		false;
	} else {
		//Allow the link to open
		true;
	}
}];
dedmen claimed this task.Jul 18 2023, 12:11 PM
dedmen added subscribers: razazel, dedmen.

As far as I could see, in Diary HTML controls, it already did fire for all links, such as links to other diary pages. EXCEPT if the link starts with # which is.. link to section.
I originally didn't want to change that, but as it was specifically requested, I'll also make it fire for section links.

Also fixed for Structured Text, now fires for all links there too.

dedmen set Ref Ticket to AIII-55783.Jul 18 2023, 12:12 PM
dedmen set Operating System to Windows 7.
dedmen changed the task status from Acknowledged to Feedback.Jul 18 2023, 12:14 PM

2.14