2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
|
# File 'lib/a-tkcommons.rb', line 2463
def __initialize_posting(_widget=self)
chs = TkWinfo.children(_widget)
hh = 22
@last_post = nil
@posting_on = true
@event_posting_on = false
@m_show = Hash.new
chs.each{|ch|
next if ch.kind_of?(String)
ch..bind_append("Map", proc{ @m_show[ch.] = true })
ch..bind_append("Unmap", proc{ @m_show[ch.] = false })
ch.bind_append("Enter", proc{|x,y,rx,ry|
if @posting_on
if @last_post && @last_post != ch.
@last_post.unpost
@last_post=nil
end
if @last_clicked && @last_clicked != ch.
@last_clicked.unpost
@last_clicked = nil
end
ch..post(x-rx,y-ry+hh)
= TkWinfo.children(ch)
@last_menu_posted = [0]
@last_menu_posted.set_focus
@last_menu_posted.bind("Enter", proc{
@last_menu_posted.bind("Leave", proc{
if @posting_on
@last_post.unpost if @last_post
@last_post = nil
@last_menu_posted.bind("Enter", proc{})
@last_menu_posted.bind("Leave", proc{})
end
})
})
end
}, "%X %Y %x %y")
ch.bind_append("Leave", proc{
ch.configure("state"=>:normal, "relief"=>:flat)
if @posting_on
if @last_post
_x = TkWinfo.x(@last_post)
_y = TkWinfo.y(@last_post)
ch.event_generate("KeyPress", :keysym=>"Escape") if Tk.focus.kind_of?(TkMenu) && Tk.focus != ch.
@last_post.post(_x,_y) if @last_clicked && @last_clicked == ch.
end
if @last_post!=ch.
@last_post=ch.
else
@last_post=nil
end
if !Tk.focus.kind_of?(TkMenu)
@last_post.unpost if @last_post
@last_post=nil
end
end
})
ch.bind_append("1", proc{|x,y,rx,ry|
@posting_on=true if @event_posting_on
if @last_post && @last_post != ch.
@last_post.unpost
@last_post = nil
end
@last_post=ch. ch.configure('state'=>'normal')
@last_clicked = ch.
@posting_on=true if @event_posting_on
}, "%X %Y %x %y")
}
_widget.bind_append("Leave", proc{
if @posting_on && Tk.focus != @last_menu_posted
@last_post.unpost if @last_post
@last_post=nil
@posting_on = false if @event_posting_on
end
TkAfter.new(1000,1, proc{
one_post = false
@m_show.each{|m,v|
one_post = v
break if v
}
@posting_on = one_post if @event_posting_on
}).start
})
end
|