Floating menu - refresh menu item

Hallo,

I have a little debug floating menu with 2 button items which visibility is toggled with Apple script to a enabled/disabled state (with those red/green buttons). It all works fine, but there is a little issue with the refresh...

Note: Only one of the two button items is actually visible.
The enabled button image is normal, while the disabled image, when visible, is slightly "dimmed".

When I running the apple script with the enable button the text in the last button is updated immediately, while the button image is only updated (=switched) when the cursor leaves the enable button (see video).

It is not a big issue, but is there a way to refresh the button visibility also immediately ?

Thx,
Christian

BTT version 4.485
MacOS : 13.6.7 (22G705)


Enabled state:

Disabled state:

Video (show pressed Enabled button) :

Enable button script:

tell application "BetterTouchTool"
	
	-- set hover frame color to standard gray - enabled state
	update_menu_item menu_name "All-fx" item_name "button_6" json "{BTTMenuItemBorderColorHover: '192, 193, 194, 255'}" with persist
	update_menu_item menu_name "All-fx" item_name "button_6_disabled" json "{BTTMenuItemBorderColorHover: '194, 195, 196, 255'}" with persist
	
	update_menu_item menu_name "All-fx" item_name "button_6" json "{BTTMenuItemVisibleWhileActive: 1}" with persist
	update_menu_item menu_name "All-fx" item_name "button_6" json "{BTTMenuItemVisibleWhileInactive: 1}" with persist
	
	update_menu_item menu_name "All-fx" item_name "button_6_disabled" json "{BTTMenuItemVisibleWhileActive: 0}" with persist
	update_menu_item menu_name "All-fx" item_name "button_6_disabled" json "{BTTMenuItemVisibleWhileInactive: 0}" with persist
		
	update_menu_item menu_name "All-fx" item_name "button_6_status" json "{BTTMenuItemText: 'enabled'}" with persist
	
end tell

How/where are you updating the image?

Hallo Andreas,

there actually two menu items/buttons with different images defined, and I "switch/toggle" the (visibility on/off) of both menu items with two apple scripts...(one for on / one for off)

Note: in this way those two buttons can have also potentially different actions.

the "enable button" / "disable button" will use a Named trigger, which contain the apple script...like so:

I see in your applescript code that every line that updates menu items finishes with "with persist".

What is the "with persist" command for?

Thx!

it saves the changes to the database, so they will still be there after restarting BTT (by default it just updates temporarily but keeps what is defined for the menu / item)

1 Like