Tk Source Code

View Ticket
Login
Ticket UUID: 1305128
Title: Scrollbar doesn't receive event
Type: Bug Version: None
Submitter: beric Created on: 2005-09-26 19:31:36
Subsystem: 16. [scrollbar] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2016-01-08 14:31:48
Resolution: Fixed Closed By: fvogel
    Closed on: 2016-01-08 14:31:48
Description:
Under Windows 2000 / XP, try the following script:

pack [scrollbar .s -orient horizontal] -fill x
bind .s <Expose> {puts "Expose"}
.s set 0 1; update
pack forget .s
.s set 0 .5; update
pack  .s -fill x  ;# Always displayed as 0 1

Then do:

event generate .s <Expose> ;# Displayed correctly
User Comments: fvogel added on 2016-01-08 14:31:48:
Merged (by Jan Nijtmans) to trunk, and cherrypicked to core-8-5-branch.

fvogel added on 2016-01-07 14:19:10:
I wanted to add a test in the test suite for this ticket.

The bug is that Tk ignored the <MapNotify> event. The scrollbar was then not redrawn by the OS using its latest context when it got mapped on screen.

AFAIK there is no way from Tk script level to check that the OS now redraws the scrollbar, thus no new test case.

fvogel added on 2016-01-05 15:38:30:

Not linked to [1510538].

On calling pack .s -fill x an idle callback to ArrangePacking is scheduled.

In ArrangePacking, Tk_MapWindow is called, which generates a MapNotify event.

This event was ignored by TkScrollbarEventProc.

The fix is therefore to deal with that event in TkScrollbarEventProc by instructing the scrollbar to be EventuallyRedraw in this case.

See branch bug-1305128fff.

The fact you manage to get the scrollbar displayed correctly by manually triggering an <Expose> event is because this event was correctly processed in TkScrollbarEventProc. However, the <Expose> event is not missing here, it is replaced by a MapNotify event which was ignored by the scrollbar.


fvogel added on 2016-01-03 20:08:19:

Similar, if not identical to [1510538] I think.


beric added on 2005-12-02 01:54:48:
Logged In: YES 
user_id=493507

The problem arise when, for example, a scrollbar is updated
in a hidden page of a notebook. It is not redrawn, since it
is unmapped, but when the notebook page is raised, it should
be redrawn by the Expose event (in tkScrollbar.c,
TkScrollbarEventProc()), which is not sent.

The same test script with a ttk::scrollbar in winnative
theme work correctly (i.e. the scrollbar is drawn according
to its value, and the <Expose> event is received at the Tcl
level).

hobbs added on 2005-12-01 10:58:20:
Logged In: YES 
user_id=72656

The scrollbar is native control, and doesn't always respond
to the Expose event as expected (an X11 term).  Perhaps
there is another way to achieve what you wanted?