The game provides events for things like that and you need to register a callback function in your addon to this event.
https://wiki.esoui.com/Events
Code:
EVENT_ACTIVE_WEAPON_PAIR_CHANGED (number eventCode, ActiveWeaponPair activeWeaponPair, boolean locked)
ActiveWeaponPair can be one of these globals:
https://wiki.esoui.com/Globals#ActiveWeaponPair
Same like starting your addon via EVENT_MANAGER:RegisterforEvent("YourAddonName_event_AddOnLoaded", EVENT_ADD_ON_LOADED, callbackFuncForEventAddOnLoaded) you need to do soemthing like:
Lua Code:
local function callbackFuncForEventActiveWeaponPairSwapped(eventId, activeWeaponPairId, locked)
if activeWeaponPairId == ACTIVE_WEAPON_PAIR_MAIN then
---your code here for weapon bar 1
elseif activeWeaponPairId == ACTIVE_WEAPON_PAIR_BACKUP then
---your code here for weapon bar 2
end
end
EVENT_MANAGER:RegisterforEvent("YourAddonName_event_active_weapon_pair_swapped", EVENT_ACTIVE_WEAPON_PAIR_CHANGED , callbackFuncForEventActiveWeaponPairSwapped)
You can find getting started, examples and tutorials here, right side:
https://wiki.esoui.com/Main_Page