public inbox for sourcenav@sourceware.org
 help / color / mirror / Atom feed
* [Patch] Fix -readonly option in combo.tcl
@ 2002-02-04 13:32 Mo DeJong
  2002-02-05  8:07 ` Syd Polk
  0 siblings, 1 reply; 2+ messages in thread
From: Mo DeJong @ 2002-02-04 13:32 UTC (permalink / raw)
  To: sourcenav

Here is a small patch that fixes the combo class so that it works
with a stock Tk 8.3. The previous version depended on some local changes
that are not available in the stock Tk 8.3 and are not in the Tk
version on sources.

Since this is a small change I assume it will be covered by the
"Small changes can be accepted without a copyright
assignment form on file" text from the contrib webpage.

Mo

2002-02-04  Mo DeJong  <supermo@bayarea.net>

	* gui/combo.tcl (-state, -readonly): Implement a read
	only entry widget with a binding that ignores all
	key press events. The previous implementation depended
	on a local modification that added a -state readonly
	property to the entry widget. We can't depend on that
	modification since it will not exist in a system
	install of Tk 8.3.
	* tests/gui/combo.test: Add test case for selecttext
	member function.

--- gui/combo.tcl	Mon Feb 26 09:15:15 2001
+++ gui/combo.tcl	Mon Feb  4 00:20:51 2002
@@ -391,8 +391,9 @@
     # as a keep option to the widgets since
     # we need to configure the entry and
     # keep track of the -readonly option.
-    # We also only want to support to
-    # -state options, normal and disabled.
+    # The -state readonly is also not available
+    # in Tk 8.3, it only supports normal
+    # and disabled.
 
     itk_option define -state state State normal {
         if {$itk_option(-state) != "normal" &&
@@ -406,22 +407,23 @@
         if {$itk_option(-state) == "disabled"} {
             $itk_component(entry) configure -state disabled
         } else {
+            $itk_component(entry) configure -state normal
+
             if {$itk_option(-readonly)} {
-                $itk_component(entry) configure -state readonly
+                bind $itk_component(entry) <KeyPress> break
             } else {
-                $itk_component(entry) configure -state normal
+                bind $itk_component(entry) <KeyPress> {}
             }
         }
     }
 
     itk_option define -readonly readOnly ReadOnly 0 {
         if {$itk_option(-readonly)} {
-            if {$itk_option(-state) == "normal"} {
-                $itk_component(entry) configure -state readonly
+            if {[string equal $itk_option(-state) "normal"]} {
+                bind $itk_component(entry) <KeyPress> break
             }
         } else {
-            $itk_component(entry) configure -state \
-                $itk_option(-state)
+            bind $itk_component(entry) <KeyPress> {}
         }
     }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch] Fix -readonly option in combo.tcl
  2002-02-04 13:32 [Patch] Fix -readonly option in combo.tcl Mo DeJong
@ 2002-02-05  8:07 ` Syd Polk
  0 siblings, 0 replies; 2+ messages in thread
From: Syd Polk @ 2002-02-05  8:07 UTC (permalink / raw)
  To: Mo DeJong; +Cc: sourcenav

This looks reasonable.

On Monday, February 4, 2002, at 01:24 , Mo DeJong wrote:

> Here is a small patch that fixes the combo class so that it works
> with a stock Tk 8.3. The previous version depended on some local changes
> that are not available in the stock Tk 8.3 and are not in the Tk
> version on sources.
>
> Since this is a small change I assume it will be covered by the
> "Small changes can be accepted without a copyright
> assignment form on file" text from the contrib webpage.
>
> Mo
>
> 2002-02-04  Mo DeJong  <supermo@bayarea.net>
>
> 	* gui/combo.tcl (-state, -readonly): Implement a read
> 	only entry widget with a binding that ignores all
> 	key press events. The previous implementation depended
> 	on a local modification that added a -state readonly
> 	property to the entry widget. We can't depend on that
> 	modification since it will not exist in a system
> 	install of Tk 8.3.
> 	* tests/gui/combo.test: Add test case for selecttext
> 	member function.
>
> --- gui/combo.tcl	Mon Feb 26 09:15:15 2001
> +++ gui/combo.tcl	Mon Feb  4 00:20:51 2002
> @@ -391,8 +391,9 @@
>      # as a keep option to the widgets since
>      # we need to configure the entry and
>      # keep track of the -readonly option.
> -    # We also only want to support to
> -    # -state options, normal and disabled.
> +    # The -state readonly is also not available
> +    # in Tk 8.3, it only supports normal
> +    # and disabled.
>
>      itk_option define -state state State normal {
>          if {$itk_option(-state) != "normal" &&
> @@ -406,22 +407,23 @@
>          if {$itk_option(-state) == "disabled"} {
>              $itk_component(entry) configure -state disabled
>          } else {
> +            $itk_component(entry) configure -state normal
> +
>              if {$itk_option(-readonly)} {
> -                $itk_component(entry) configure -state readonly
> +                bind $itk_component(entry) <KeyPress> break
>              } else {
> -                $itk_component(entry) configure -state normal
> +                bind $itk_component(entry) <KeyPress> {}
>              }
>          }
>      }
>
>      itk_option define -readonly readOnly ReadOnly 0 {
>          if {$itk_option(-readonly)} {
> -            if {$itk_option(-state) == "normal"} {
> -                $itk_component(entry) configure -state readonly
> +            if {[string equal $itk_option(-state) "normal"]} {
> +                bind $itk_component(entry) <KeyPress> break
>              }
>          } else {
> -            $itk_component(entry) configure -state \
> -                $itk_option(-state)
> +            bind $itk_component(entry) <KeyPress> {}
>          }
>      }
>
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-02-04 22:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-04 13:32 [Patch] Fix -readonly option in combo.tcl Mo DeJong
2002-02-05  8:07 ` Syd Polk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).