

DEBUT DE DESCRIPTION DE LA GESTION DE FOCUS

UTILISER DE PREFERENCE LES NOUVELLES PROC DE "tk.tcl"
A terme, il faudrait les incorporer dans stead, ou dans 
un nouveau package xtk.

extrait d'une boite de dialogue les utilisant :

Voici la description dtaille de l'utilisation de ces commandes :

    # ... 
    # FIN de cration de la toplevel et de ces widgets et binding 
    ####################################################################
    
    ####################################################################
    # La suite peut devenir quasi standard (toujours pareil)    
    ####################################################################
    # 
    # 
    # baratin  rajouter ??
    wm transient $w $data(-parent)
    
    # ::tk::PlaceWindow -- (from tk.tcl)
    # Withdraw the window, then update all the geometry information
    # so we know how big it wants to be, then center the window in the
    # display and de-iconify it.
    # 
    # Arguments:
    #   toplevel    name of toplevel window
    #   ?placement?
    #       pointer ?center? ; places $w centered on the pointer
    #       widget widgetPath ; centers $w over widget_name
    #       defaults to placing toplevel in the middle of the screen
    #   ?anchor?    center or widgetPath
    # Results:
    #   Returns nothing
    # 
    # 
    ::tk::PlaceWindow $w widget $data(-parent)
    
    # Est-on vraiment oblig d'attendre que la toplevel soit affiche
    # pour pouvoir changer son titre ?? sinon  dplacer en amont !
    wm title $w $data(-title)
    
    # ::tk::SetFocusGrab -- (from tk.tcl)
    #   swap out current focus and grab temporarily (for dialogs)
    # Arguments:
    #   grab    new window to grab
    #   focus   window to give focus to
    # Results:
    #   Returns nothing
    #
    ::tk::SetFocusGrab $w $data(ent)
    
    # Wait for the user to respond, then restore the focus and
    # return the index of the selected button.  Restore the focus
    # before deleting the window, since otherwise the window manager
    # may take the focus away so we can't redirect it.  Finally,
    # restore any grab that was in effect.

    tkwait variable [set dataName](result)

    # ::tk::RestoreFocusGrab -- (from tk.tcl)
    #   restore old focus and grab (for dialogs)
    # Arguments:
    #   grab	window that had taken grab
    #   focus	window that had taken focus
    #   destroy | withdraw  - how to handle the old grabbed window
    # Results:
    #   Returns nothing
    #
    ::tk::RestoreFocusGrab $w $data(ent) destroy


    # Cleanup traces on selectPath variable
    #
    # ...

    update 
    
    # # return $j_prompt(result)
    return $data(result)
    ##################################################################

Si on souhaite effectivement utiliser les procdures prive ::tk:: 
l'utilisation de ces commandes prend peu de place sans les 
commentaires. A titre d'exemple faire la fin du browser te:fs :

    
      wm transient $w $j_fs(-parent)
      ::tk::PlaceWindow $w widget $j_fs(-parent)
      wm title $w $j_fs(-title)
      ::tk::SetFocusGrab $w $w.file.e
      tkwait variable j_fs(result)
      ::tk::RestoreFocusGrab $w $w.file.e destroy

      return $j_fs(result)


Si on souhaite etre indpendant de ::tk:: (priv),
on peut donc envisager une procdure polyvalante qui rduirait le morceau 
de code prcdent  :
    
    xtk:placeDialogue $theTopLevel \
         -transient      1
         -parent         $data(-parent)
         -relativeto     widget   (ou -relativeto window)
         -title          $data(-title)
         -focusgrab      $data(ent)
         -variabletowait [set dataName](result)
         -whenrestored   destroy
    
Cette procdure devrait peut-etre inclure en dure le contenu des
procdure prives ::tk::xxx qui ne sont pas encore officiellement 
documentes dans le man de tk

######################################################################
