Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Snit widgets and bindings under Etcl
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
relaxmike  
View profile  
 More options Dec 2 2008, 11:14 am
Newsgroups: comp.lang.tcl
From: relaxmike <michael.bau...@gmail.com>
Date: Tue, 2 Dec 2008 08:14:00 -0800 (PST)
Subject: Snit widgets and bindings under Etcl
Hi All Tclers,

I have the following problem that my Snit-based extended text widget
does not behave as I want : the events I generate from the script
are not captured, while interactive events are. That make the unit
tests
difficult to perform.

The following script is the smallest I can write which exhibits the
problem.
It creates a snit widgetadaptor above Tk's text.
The insert method is modified so that it inserts the letter, then a
"!".
In the end of the script, I generate the event associated with the
"a" key.

package require Tk
package require snit
::snit::widgetadaptor rptext {
  constructor {args} {
    installhull using text
    $self configurelist $args
  }
  method insert {args} {
    set cmd [list $hull insert]
    set cmd [concat $cmd $args]
    eval $cmd
    $hull insert insert "!"
    return ""
  }
  method delete {args} {}
  # Enable ins and del as synonyms, so the program can insert and
  # delete.
  delegate method ins to hull as insert
  delegate method del to hull as delete
  # Pass all other methods and options to the real text widget, so
  # that the remaining behavior is as expected.
  delegate method * to hull
  delegate option * to hull

}

frame .f1
pack .f1
button .f1.bn1 -text "X" -command {exit}
pack .f1.bn1 -side left
button .f1.bn2 -text "A" -command {
  focus .mytext
  event generate .mytext <Key-A>
}

pack .f1.bn2 -side left
rptext .mytext -height 8 -width 40
pack .mytext
update
focus  .mytext
event generate .mytext <Key-a>
update

When this script is executed on my Pocket PC 4100 with Etcl 19/09/2008
running under Windows CE, the text widget is displayed but the "a!"
text
is not displayed. But when I interactively type on my virtual
keyboard,
the events are processed normally.

When I execute the same script on my Win XP station with AS Tcl
8.4.19,
the text appears with a "a!" at the beginning, as expected (as well
as interactively typed letters of course).

From my experience, I noticed that the following rules
must be satisfied so that the events generated can be captured :
- the widget must be packed,
- the widget must have the focus
- the update command must be executed, to force the event
loop to process the event.
When I apply these rules, the "event generate" instructions I use in
my unit
tests generally get processed.

But not here  : do you have any idea why ?

Best regards,

Michaël


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.