Please make onHTMLLink fire when clicking on links to sections. Currently it only fires when clicking an external link.
Description
Details
- Legacy ID
- 2655333559
- Severity
- None
- Resolution
- Open
- Reproducibility
- N/A
- Operating System
- Windows 7
- Category
- Feature Request
Event Timeline
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; } }];
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.