Updating mainmenu items before show lazarus / 21-General ---------------------------------------------------------------------- torbente · 2021-01-23 01:47 I am implementing a main menu, but there are some items that must change it caption according to the value of some variables. For example: An item have "Start counting" But if the app is already counting, the item must say "Stop Counting" Is there any way to verify a variable when the  mainmenu is clicked, BEFORE it shows the items? IF so, i could so something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i counting : boolean;If counting then MainMenu.Items[0].Caption :='Stop counting'else MainMenu.Items[0].Caption :='Start counting'; ---------------------------------------------------------------------- lucamar · 2021-01-23 03:47 Quote from: torbente on January 23, 2021, 02:47:59 amIs there any way to verify a variable when the  mainmenu is clicked, BEFORE it shows the items?Yes, attach a handler to the OnClick event of the (main)menu item. It's often used for e.g. an "Edit" item where you want to (de)activate Cut/Copy/Paste/etc. depending on whether some control has a selection or the state of the clipboard. ---------------------------------------------------------------------- torbente · 2021-01-23 06:02 But in that case the menu item was already show. I understood now! Quote from: lucamar on January 23, 2021, 04:47:38 amQuote from: torbente on January 23, 2021, 02:47:59 amIs there any way to verify a variable when the  mainmenu is clicked, BEFORE it shows the items?Yes, attach a handler to the OnClick event of the (main)menu item. It's often used for e.g. an "Edit" item where you want to (de)activate Cut/Copy/Paste/etc. depending on whether some control has a selection or the state of the clipboard.