Ticket UUID: | c92cee4740d33ccfd3f45e06cebab0bd83a9ad45 | |||
Title: | Deselect radiobutton | |||
Type: | Bug | Version: | 8.6 | |
Submitter: | anonymous | Created on: | 2018-09-15 15:39:45 | |
Subsystem: | 03. [*button] and [label] | Assigned To: | fvogel | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2019-09-02 18:21:09 | |
Resolution: | Invalid | Closed By: | fvogel | |
Closed on: | 2019-09-02 18:21:09 | |||
Description: |
frame .t pack .t set reptype 0 radiobutton .t.r1 -text "1" -variable reptyp -value 1 radiobutton .t.r2 -text "2" -variable reptyp -value 2 radiobutton .t.r3 -text "3" -variable reptyp -value 3 radiobutton .t.r4 -text "4" -variable reptyp -value 4 radiobutton .t.r5 -text "5" -variable reptyp -value 5 radiobutton .t.r6 -text "6" -variable reptyp -value 6 bind .t.r1 <Double-1> {Chk_Alone $reptyp} bind .t.r2 <Double-1> {Chk_Alone $reptyp} bind .t.r3 <Double-1> {Chk_Alone $reptyp} bind .t.r4 <Double-1> {Chk_Alone $reptyp} bind .t.r5 <Double-1> {Chk_Alone $reptyp} bind .t.r6 <Double-1> {Chk_Alone $reptyp} grid .t.r1 grid .t.r2 grid .t.r3 grid .t.r4 grid .t.r5 grid .t.r6 proc Chk_Alone {args} { global reptyp #tk_messageBox -message "unselected" after idle [list .t.r$args deselect ] } #is a short exemple deselect not work, work only if tk_message is not a comment | |||
User Comments: |
fvogel added on 2019-09-02 18:21:09:
(text/x-fossil-wiki)
I don't think there is a bug here. The radiobutton is set upon <ButtonRelease> event, and this fires before or after the idle command depending on the presence of the tk_messageBox that precedes it. 1. With: <verbatim> proc Chk_Alone {args} { global reptyp puts IN after idle [list .t.r$args deselect ; puts DONE] puts OUT } </verbatim> Sequence of events: <Button-1> <ButtonRelease> <Double-1> IN DONE OUT <ButtonRelease> * The double click on button-1 fires the binding running the Chk_Alone proc, and this proc simply schedules a deselect command (that sets 'reptype' to the empty string, thus selecting all radiobuttons with -variable reptype). This command executes at next idle time. * <ButtonRelease> fires at the very end, which sets the clicked radiobutton 2. With: <verbatim> proc Chk_Alone {args} { global reptyp puts IN tk_messageBox -message "unselected" after idle [list .t.r$args deselect ; puts DONE] puts OUT } </verbatim> Sequence of events: <Button-1> <ButtonRelease> <Double-1> IN <ButtonRelease> DONE OUT * The difference here is that the tk_messageBox enters the event loop (through vwait), which services the <ButtonRelease> event that was queued. This event is therefore no longer queued and the deselect command is the last thing to execute, contrary to the previous case. To achieve what you seem to want, you can remove the tk_messageBox and use 'after 0' instead of 'after idle'. bll added on 2018-09-16 16:52:37: See also: http://core.tcl.tk/tcl/info/7f08437314ca213f bll added on 2018-09-16 15:37:05: Well, crap. I automatically look at ttk::radiobutton. Force of habit. Sorry. fvogel added on 2018-09-16 15:30:02: http://www.tcl.tk/man/tcl8.6/TkCmd/radiobutton.htm#M23 bll added on 2018-09-16 15:09:40: Oh, really? Which manual page are you finding that in? What version? I see no deselect. fvogel added on 2018-09-16 15:02:56: deselect definitely is a documented and supported command for radiobuttons. That said I have no idea about what the OP strives to achieve. It is far from obvious there is a bug here. Best would have been to post this question on comp.lang.tcl first. bll added on 2018-09-15 18:05:18: deselect is not a supported command. Just set reptype to 0. |