Welcome Guest Search | Active Topics | Sign In | Register

ToolBar DropDownMenu Item click issue Options
matrixy
Posted: Thursday, December 30, 2010 2:32:16 PM
Rank: Member
Groups: Member

Joined: 12/27/2010
Posts: 14
I am using the Toolbar control .. one of the toolbar items is a dropdownmenu item. I have created a context menu and passed its ID to the dropedownMenuItemID .. The problem is that I have to click on a very narrow area of the toolbar item for the drop down to appear ...

This has driven me crazy for the last three hours .. Please help ..

Also, can the drop down menu appear on hover in addition to the click event ?

eo_support
Posted: Thursday, December 30, 2010 3:37:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can handle the toolbar's ClientSideOnItemClick and then call our client side JavaScript interface to display the sub menu. That way you can display the sub menu whenever you wanted.

If you have not used our client side API before, you will want to go over this topic first:

http://doc.essentialobjects.com/library/1/clientapi_howto.aspx

Thanks!
matrixy
Posted: Thursday, December 30, 2010 4:11:15 PM
Rank: Member
Groups: Member

Joined: 12/27/2010
Posts: 14
Thanks for your support but I think this should be fixed without having to write java script code ..

By the way, i have used the below function to show the context menu but it now shows on any on the item tool bar click .. Now, do I have to go through the pain of knowing which toolbaritem triggered the click and then display its related context menu ? is there any way around this ?

function on_item_click(toolBar, toolBarItem, subMenu)
{
eo_ShowContextMenu(event, 'ContextMenu1');
}
eo_support
Posted: Thursday, December 30, 2010 4:22:05 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Yes. You do need to write code for those. This is the designed behavior and we have no intention to "fix" anything here. The basic idea is there can be only one default behavior and that is usually how most people wanted it to work. If you want anything "non-default", then we try to make the control as flexible as possible so that you will be able to implement yourself with our programming interface. We can not change the default behavior because then some other users will want us to change it back. We do not want to add a ton of options on the controls either because that will confuse users who are not interested in such options.

The bottom line is there is a fine balance between what's done by the control and what's done by your code. If we do too little, it will be a lot of code for everybody. If we do too much, then not only you will get a bloated product with a load of options that you don't know what they are about, but the flexibility of the product will suffer greatly because there are too much built-in logic.

In your case checking which item is clicked is no pain at all because it's passed in through the second argument.

Thanks
matrixy
Posted: Thursday, December 30, 2010 4:27:42 PM
Rank: Member
Groups: Member

Joined: 12/27/2010
Posts: 14
Thanks .. I get your point .. I think you are right .. but don't you also believe that the above situation in my screen shot is a bug ? I mean the clicking is not working on all of the toolbar item ! ..

Also, now I am having a second issue which is the context menu is appearing relative to my mouse click so if i click on top of the item, the context will appear over the toolbar item itself and so forth .. can you tell me please if I can make the context always start rendering from below the toolbar item just as it looks like in the screen shot in my first post above ?

Thanks again
matrixy
Posted: Thursday, December 30, 2010 4:32:23 PM
Rank: Member
Groups: Member

Joined: 12/27/2010
Posts: 14
Now, the clicking event is only triggered in IE not in Fire Fox .. the context doesn't appear in fire fox .. man your help please .. I always felt that if one has to do manual java script then things will get ugly ..
eo_support
Posted: Thursday, December 30, 2010 4:53:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

That is not a bug. See here for a working example:

http://demo.essentialobjects.com/Demos/Tool%20Bar/Features/Drop%20Down%20Item/Demo.aspx

Note that this sample has a drop down menu for the "New" item. The item displays a drop down triangle icon next to the toolbar text. This is done by using a CSS background image aligned to the right on the toolbar item's styles (NormalStyle, HoverStyle and DownStyle). You can check the sample source code for more details. You can also set the toolbar item's DropDownButtonWidth to control the width of the clickable area that would open you drop down menu.

In order to align your menu to the toolbar item, you will need to pass the toolbar item's root DOM element to eo_ShowContextMenu. It will be something like this:

eo_ShowContextMenu(toolBarItem.getElement(), 'ContextMenu1');

You can further fine tune the position of the context menu by setting OffsetX and OffsetY on the "TopGroup" of your ContextMenu object.

There is no such thing as thing will go ugly if you do JavaScript. You just have to do it right. In your case you copied the code from the document but did not understand that “event” is not valid for FireFox in your context (the samples’ context is in oncontextmenu handler, your case is not).

The basic rule is if you wanted something advance, then you will need to code for it. If you do not wish to code for it, then you will need to settle with basic/default things. We can point you to the right direction most of the time but we are a component vendor and there is no way we can make a product so nobody will ever need to code. (Otherwise your boss would just buy our product and ask you go home. : P). Our goal is to make a product that is both easy to use for beginners and very powerful/flexible for advanced users at the same time.

Thanks!
matrixy
Posted: Thursday, December 30, 2010 5:21:32 PM
Rank: Member
Groups: Member

Joined: 12/27/2010
Posts: 14
Thanks for clearing that out ..

The DropDownButtonWidth didn't fix it for me , it just added more padding space but didn't cover the text area of the tool bar item. But I used java script as you mentioned and it did work now correctly on both browsers ..

Thanks again for your quick and informative responses...
matrixy
Posted: Friday, December 31, 2010 4:54:38 AM
Rank: Member
Groups: Member

Joined: 12/27/2010
Posts: 14
One final question please, is there a way to pass the context submenu id when the toolbar item is clicked ? the current situation is that i'm passing the entire context menu object .. so that means I have to create multiple context menus for every toolbar item I want to expand ... isn't there a way to only pass the submenu id of the context menu without passing the entire context menu object itself ?

Thanks
eo_support
Posted: Friday, December 31, 2010 8:52:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Yes. You would create multiple sub menus in your context menu, then set the parent item of each sub menu to a unique value. For example, you menu can be like this:

top level: File | Edit | Help
File sub menu: Open | Exit
Edit sub menu: Copy | Cut | Paste
Help sub menu: About | Help

You can then set top level item File's ItemID to "file" and then open the file sub menu only with the following code:

eo_ShowContextMenu(e, "ContextMenu1", "file");

Note the third argument is what tells eo_ShowContextMenu which sub menu to display. Without that argument, it will display the "top group", which would be "File | Edit | Help". But once a value is supplied, it would try to locate a menu item with the matching ItemID value, then display the sub menu of that menu item, in this case, it would be "Open | Exit".

Hope this helps.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.