Tk Library Source Code

View Ticket
Login
Ticket UUID: 470273
Title: BWidget: MainFrame menu inconsistency
Type: Patch Version: None
Submitter: bach Created on: 2001-10-11 15:38:53
Subsystem: bwidget Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-12-29 08:02:02
Resolution: Fixed Closed By: hobbs
    Closed on: 2001-12-29 01:02:02
Description:
Motivation:
-----------

The BWidget MainFrame widget shows a slight
inconsistency in the
handling of menu (de-)activation when using multiple
tags.

Consider this small example:

------- snip
package require BWidget
set descmenu {
 "&File" all file 0 {
  {command "Exit 1" {tag_bla tag1} "" {} -command exit}
  {command "Exit 2" {tag_bla tag2} "" {} -command exit}
 }
}
set mainframe [MainFrame .mainframe -menu $descmenu]
pack $mainframe -expand yes -fill both

#$mainframe setmenustate tag1 normal
------- snap

Start the program, both menuentries are active. Now,
remove the comment #
from the setmenustate line, start the program: the
"Exit 1"-entry is
suddenly _disabled_ instead of normal.


Discussion:
-----------
Internally, BWidget uses the tags as boolean states
whether a menu
should be shown normal or disabled. Only if each and
every tag is set
to normal (1) the entry is displayed in normal state.

Unfortunately, the default initialization of the
entries is set to 0
(disabled)! (The menues after the start do not reflect
this, they are
all normal).

For the example given above, after init, one has this:

  tag_bla 0
  tag1    0
  tag2    0

After the setmenustate, tag1 is 1, but tag_bla is still
0, making the
entry be displayed as disabled (0).

Possible remedies:
------------------
1) have MainFrame make a refresh of the Menudisplay
according to the
    tags. This would probably break a great many
existing applications
    that do not set the tags explicitly to normal.
2) document this as a known quirk and have everyone
maually set all
    the tags to normal with setmenustate when starting
their program
3) change the behaviour of the default initialization
to 1 (normal).
    This *could* break existing programs who rely on
this
    ... undocumented feature, but I doubt it.

I'd tend to 3), as I see this as the expected
behaviour. Anyway, I
attached the patches for it (they fix the same problem
for the menus
themselves, too) in diff -c format.

The line must be changed in 
  proc MainFrame::_create_menubar { path descmenu } 
and 
  proc MainFrame::_create_entries { path menu bg
entries } {


Bastien
User Comments: hobbs added on 2001-12-29 08:02:02:
Logged In: YES 
user_id=72656

patched for 1.3.2cvs.

bach added on 2001-10-11 22:40:48:

File Added - 11855: ttt

bach added on 2001-10-11 22:40:47:
Logged In: YES 
user_id=98533

I'll learn to make a bug/patch report right the first time
sometimes, promised. (forgot the diff -c file)

Attachments: