List Info

Thread: Dynamic Task Bar Menu Items




Dynamic Task Bar Menu Items
country flaguser name
United States
2007-12-17 21:47:02
Am looking for a way to dynamically add menu items to a task
bar icon 
menu. And then once selected - I would like to get the title
of the menu 
item. The general idea is to read a text file:
Project1
Project2
Project3
=====
Add those to the task bar menu, and when i select (for
example) 
Project2, I want to pass the string "Project2" to
the code.

Also - Am wondering about how to get the menu to respond to
the left 
mouse button click - as opposed to the right one by
default.
_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users

Re: Dynamic Task Bar Menu Items
country flaguser name
United Kingdom
2007-12-18 03:25:32
Hi

Firstly, take a look at the sample
"bigdemo/bigdemo.rb" and look for the 
class DemoTaskBarIcon. I think it demonstrates most of what
you want to do.

EchoB wrote:
> Am looking for a way to dynamically add menu items to a
task bar icon 
> menu. 
Define a method "create_popup_menu" in your
TaskBarIcon subclass. This 
will be called on each occasion that the menu is shown, so
simply create 
the menu with the appropriate items at any given time.
> And then once selected - I would like to get the title
of the menu 
> item. 
Use evt_menu to get the menu item selected, then use
Wx::Menu#get_label 
to get the text string for that item. Imagine that in
create_popup_menu 
you store the menu as an instance variable menu, you
could do the 
following in your TaskBarIcon initialize method to capture
all menu 
events and show the text label.

evt_menu(Wx::ID_ANY) do | event |
  puts menu.label(event.id)
end

> Also - Am wondering about how to get the menu to
respond to the left 
> mouse button click - as opposed to the right one by
default.
use evt_taskbar_left_down or evt_taskbar_left_up. Take a
look at the 
TaskBarIcon and Menu documentation - I think this should all
be covered, 
but please get in touch if anything's not clear.

http
://wxruby.rubyforge.org/doc/taskbaricon.html
http://wxru
by.rubyforge.org/doc/menu.html

cheers
alex
_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )