Welcome Guest Search | Active Topics | Sign In | Register

editor vs toolbar ClientSideOnItemClick Options
bobwolf
Posted: Tuesday, October 5, 2010 2:31:25 PM
Rank: Member
Groups: Member

Joined: 5/31/2008
Posts: 25
Hi guys,
When I use a separeted Toolbar control, I can set the propery ClientSideOnItemClick to intercept client clicks.

But, I want to intercept clicks on my Editor Toolbar.
How to set the "ClientSideOnItemClick" for my Editor toolbar?


Tks in advance.
Roberto Wolf.
eo_support
Posted: Tuesday, October 5, 2010 3:23:28 PM
Rank: Administration
Groups: Administration

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

You won't be able to do that directly on Editor ToolBar because the Editor will intercept and handle all toolbar click event. You can find more information about how to add custom toolbar button to an Editor toolbar here:

http://www.essentialobjects.com/forum/postst4630_How-to-add-custom-dialogbuttons-to-Editor-toolbar.aspx

Thanks!
bobwolf
Posted: Tuesday, October 5, 2010 4:26:11 PM
Rank: Member
Groups: Member

Joined: 5/31/2008
Posts: 25
Thanks for reply.

I try to reach this using the custom Toolbar.

The main problem is that I need to use the "ToolBarItems" property to define button order.
The property "ToolBarItems" will be ignored if I use a custom Toolbar to create a button. Correct?

How can I set the "ToolBarItems" (for my 15 buttons ordered by current logged user) and after create only a 1 custom button?


Tks.
Roberto.
eo_support
Posted: Tuesday, October 5, 2010 5:04:04 PM
Rank: Administration
Groups: Administration

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

You are correct. There is no way for you to use custom button but also use ToolBarItems at the same time. However you should be able to dynamically show/hide certain toolbar items through code. It will be something like this:

Code: C#
//Get the toolbar control
EO.Web.ToolBar toolBar = (EO.Web.ToolBar)
    Editor1.HeaderContainer.FindControl("ToolBar1");

//Show/hide a tool bar item
toolBar.Items[x].Visible = true/false;


You will need to replace "Editor1", "ToolBar1" with the corresponding control ID and "x" with the index of the item you wish to show or hide.

Thanks!

bobwolf
Posted: Wednesday, October 6, 2010 8:57:40 AM
Rank: Member
Groups: Member

Joined: 5/31/2008
Posts: 25
In this case, I can use a toolbar reference to set my client side script? No?

Like this:

Code: C#
//Get the toolbar control
EO.Web.ToolBar toolBar = (EO.Web.ToolBar)txtMessage.HeaderContainer.Controls[0];

//Set javascript function for client side item click
toolBar.ClientSideOnItemClick = "on_toolbaritem_click";


Looks fine to me.
Are there any side effects using this?


Tks.
Roberto.
eo_support
Posted: Wednesday, October 6, 2010 9:37:25 AM
Rank: Administration
Groups: Administration

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

I believe that will work. In fact that has no difference than setting the ToolBar's ClientSideOnItemClick directly in your header template --- which actually goes back to your original question, you can set it by right click the Editor, then select Edit Template -> CustomHeaderTemplate from the context menu.

Possible side effects depend on what you do in your handler. One main issue is many editor commands rely on the current selection, which can change if the editor loses focus. So if your handler code does anything that can cause the editor to temporarily or permanently lose focus, then it might cause problem. However if you are just adding your custom buttons then it should be fine.

Thanks!
bobwolf
Posted: Wednesday, October 6, 2010 10:01:09 AM
Rank: Member
Groups: Member

Joined: 5/31/2008
Posts: 25
Cool!

Instead of create a new custom item in toolbar, I will only redefine the DesignMode button to do other stuff (show/hide some divs).

My last question for this subject:
In the Toolbar client side script are there any way to "cancel" an user item click, for example, the user clicks on DesigMode button can I cancel the DesignMode action and only do some other action?
Or I need to change the Mode again in client side, after running my other stuff (actually I'm doing this via settimeout script...)?

Tks!
Roberto.
eo_support
Posted: Wednesday, October 6, 2010 11:25:45 AM
Rank: Administration
Groups: Administration

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

I believe you can cancel it by returning false from your handler.

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.