Work
This commit is contained in:
@@ -15,7 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
LIABILITY, .HETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
@@ -166,3 +166,33 @@ func (w *TopMenuLayout) Log(txt string, args ...any) {
|
||||
w.logger(txt, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *TopMenuLayout) CreateMenuItem(id, lbl string, do func() bool, subItems ...*MenuItem) *MenuItem {
|
||||
d := NewMenuItem(id, tcell.StyleDefault)
|
||||
d.SetLabel(lbl)
|
||||
d.SetOnPressed(do)
|
||||
if len(subItems) > 0 {
|
||||
d.AddItems(subItems...)
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (w *TopMenuLayout) SetItemVisible(id string, v bool) bool {
|
||||
if mi := w.FindItem(id); mi != nil {
|
||||
w.Log("%s.SetItemVisible: Found Item: %s (Set Visible: %t)", w.Id(), id, v)
|
||||
mi.SetVisible(v)
|
||||
return true
|
||||
}
|
||||
w.Log("%s.SetItemVisible: Didn't find item with id: %s", w.Id(), id)
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *TopMenuLayout) SetItemDisabled(id string, d bool) bool {
|
||||
if mi := w.FindItem(id); mi != nil {
|
||||
mi.SetDisabled(d)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *TopMenuLayout) FindItem(id string) *MenuItem { return w.menu.FindItem(id) }
|
||||
|
||||
Reference in New Issue
Block a user