# Adding menu items to a TaskBar

**URL:** <https://www.ruby-forum.com/t/adding-menu-items-to-a-taskbar/125979>\
**Category:** wxRuby\
**Created:** [January 14, 2008, 12:20pm UTC](https://www.ruby-forum.com/t/adding-menu-items-to-a-taskbar/125979 "2008-01-14T12:20:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [January 14, 2008, 12:20pm UTC](https://www.ruby-forum.com/t/adding-menu-items-to-a-taskbar/125979/1 "2008-01-14T12:20:42Z")

</div>

Hello  
I’m looking for a way to add menu items to a task bar icon menu.  
I have created a popup menu.  
And I want to add to a task bar icon menu items for example projects but  
it must be after user log in.

1. User log in
2. getting list of projects
3. adding menu items into task bar menu with project  
I attch a file with source code which I already written  
Thenks for reply’s

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [January 14, 2008, 12:29pm UTC](https://www.ruby-forum.com/t/adding-menu-items-to-a-taskbar/125979/2 "2008-01-14T12:29:07Z")

</div>

Anton K. wrote:

> I’m looking for a way to add menu items to a task bar icon menu.  
> I have created a popup menu.  
> And I want to add to a task bar icon menu items for example projects but  
> it must be after user log in.
> 
> 1. User log in
> 2. getting list of projects
> 3. adding menu items into task bar menu with project  
> I attch a file with source code which I already written

This came up recently on the mailing list:

[http://rubyforge.org/pipermail/wxruby-users/2007-December/003506.html](http://rubyforge.org/pipermail/wxruby-users/2007-December/003506.html)

Basically, just have your create\_popup\_menu method check whether the  
login has taken place, and show the appropriate menu items. The method’s  
called anew each time the menu is shown.

alex

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [January 14, 2008, 12:51pm UTC](https://www.ruby-forum.com/t/adding-menu-items-to-a-taskbar/125979/3 "2008-01-14T12:51:27Z")

</div>

Yes I was read this message before write my post.  
I’m quite new in Ruby and not understand this code ☹  
actually I understand what this code doing but I don’t understand how I  
can use this code in my project.  
Thanks for reply

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [January 14, 2008, 6:02pm UTC](https://www.ruby-forum.com/t/adding-menu-items-to-a-taskbar/125979/4 "2008-01-14T18:02:16Z")

</div>

Anton K. wrote:

> Yes I was read this message before write my post.  
> I’m quite new in Ruby and not understand this code ☹  
> actually I understand what this code doing but I don’t understand how I  
> can use this code in my project  
> Have you actually tried working at it? As the previous emails said,  
> create\_popup\_menu is called EVERY time the user clicks on the taskbar  
> icon. So if the contents of that menu should change depending on the  
> program’s state (eg if the user is logged in), test for that state in  
> create\_popup\_menu and the correct menu will be shown.

From your example, what you could change is move the “if @user.login?”  
test into create\_popup\_menu. If the user is logged in, show the extra  
project menu items, if not, don’t.

hth  
alex
