@@ -548,6 +548,19 @@ def bell
548
548
tk_call 'bell'
549
549
end
550
550
551
+ def Tk . focus ( display = nil )
552
+ if display == nil
553
+ r = tk_call ( 'focus' )
554
+ else
555
+ r = tk_call ( 'focus' , '-displayof' , display )
556
+ end
557
+ tk_tcl2ruby ( r )
558
+ end
559
+
560
+ def Tk . focus_lastfor ( win )
561
+ tk_tcl2ruby ( tk_call ( 'focus' , '-lastfor' , win ) )
562
+ end
563
+
551
564
def toUTF8 ( str , encoding )
552
565
INTERP . _toUTF8 ( str , encoding )
553
566
end
@@ -636,9 +649,15 @@ def overrideredirect(bool=None)
636
649
def positionfrom ( *args )
637
650
tk_call 'wm' , 'positionfrom' , path , *args
638
651
end
639
- def protocol ( name , func = None )
640
- func = install_cmd ( func ) if not func == None
641
- tk_call 'wm' , 'command' , path , name , func
652
+ def protocol ( name = nil , cmd = nil )
653
+ if cmd
654
+ tk_call ( 'wm' , 'protocol' , path , name , cmd )
655
+ elsif name
656
+ result = tk_call ( 'wm' , 'protocol' , path , name )
657
+ ( result == "" ) ? nil : tk_tcl2ruby ( result )
658
+ else
659
+ tk_split_simplelist ( tk_call ( 'wm' , 'protocol' , path ) )
660
+ end
642
661
end
643
662
def resizable ( *args )
644
663
w = tk_call ( 'wm' , 'resizable' , path , *args )
@@ -1402,8 +1421,8 @@ def add pat, value, pri=None
1402
1421
def clear
1403
1422
tk_call 'option' , 'clear'
1404
1423
end
1405
- def get win , classname , name
1406
- tk_call 'option' , 'get' , classname , name
1424
+ def get win , name , klass
1425
+ tk_call 'option' , 'get' , win , name , klass
1407
1426
end
1408
1427
def readfile file , pri = None
1409
1428
tk_call 'option' , 'readfile' , file , pri
@@ -1735,8 +1754,12 @@ def place_slaves()
1735
1754
list ( tk_call ( 'place' , 'slaves' , epath ) )
1736
1755
end
1737
1756
1738
- def focus
1739
- tk_call 'focus' , path
1757
+ def focus ( force = false )
1758
+ if force
1759
+ tk_call 'focus' , '-force' , path
1760
+ else
1761
+ tk_call 'focus' , path
1762
+ end
1740
1763
self
1741
1764
end
1742
1765
0 commit comments