Re[6]: DHTML Editor
От: masha  
Дата: 07.11.01 09:54
Оценка: 11 (2)
Здравствуйте!

Хочу рассказать как менять свойсва объектов(таблиц, картинок, ссылок,...) в DHTMLEdit.

Во-первых на странице с контролом нужно "зарегистрировать" два события:

<script FOR="myEditor" EVENT="ShowContextMenu(xPos, yPos)">
ShowContextMenu();
</script>
<script FOR="myEditor" EVENT="ContextMenuAction(iIndex)">
ContentMenuAction(iIndex);
</script>

Во-вторых написать обработчики для этих событий, например, так:

var TableContextMenu = new Array();
var TableContextAction = new Array();

TableContextMenu["str"] = new Array();
TableContextMenu["state"] = new Array();

TableContextMenu["str"].push("Cut");
TableContextMenu["str"].push("Copy");
TableContextMenu["str"].push("Paste");
TableContextMenu["str"].push("Insert Row");
TableContextMenu["str"].push("Insert Column");
TableContextMenu["str"].push("Delete Rows");
TableContextMenu["str"].push("Delete Columns");
TableContextMenu["str"].push("Split Cells");
TableContextMenu["str"].push("Merge Cells");
TableContextMenu["str"].push("Properties");

TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_GRAY);
TableContextMenu["state"].push(OLE_TRISTATE_UNCHECKED);

TableContextAction.push(DECMD_CUT);
TableContextAction.push(DECMD_COPY);
TableContextAction.push(DECMD_PASTE);
TableContextAction.push(DECMD_INSERTROW);
TableContextAction.push(DECMD_INSERTCOL);
TableContextAction.push(DECMD_DELETEROWS);
TableContextAction.push(DECMD_DELETECOLS);
TableContextAction.push(DECMD_SPLITCELL);
TableContextAction.push(DECMD_MERGECELLS);
TblContextActLen = TableContextAction.push(DECMD_PROPERTIES);

function ShowContextMenu(){

if (!HTMLMode) {
for(i=0; i<TblContextActLen-1; i++) {
if ( EditObj.QueryStatus(TableContextAction[i]) == DECMDF_ENABLED ) {
TableContextMenu["state"][i] = OLE_TRISTATE_UNCHECKED;
}
else {
TableContextMenu["state"][i] = OLE_TRISTATE_GRAY;
}
}
EditObj.SetContextMenu(TableContextMenu["str"], TableContextMenu["state"]);
} else {
alert ("Не работает в режиме HTML");
}
}

function ContentMenuAction(ind) {

if (!HTMLMode) {
if (ind < TblContextActLen-1 ) {
EditObj.ExecCommand(TableContextAction[ind]);
}
else {
sel = EditObj.DOM.selection;
if (sel.type == "Control") {
ctlRg = sel.createRange();

ctlObj = ctlRg(0);

if (ctlObj.tagName == "IMG") {

var res = new Array();
res = window.showModalDialog("PicDetails.asp", "align=" + ctlObj.align + " alt=" + ctlObj.alt, "dialogWidth: 450px; dialogHeight: 300px; font-family: Verdana, Arial; font-size: 8pt;")
if (res != null) {
PicAlign = res["PicAlign"];
PicAlt = res["PicAlt"];

if ( PicAlign.length > 0 ) {
ctlRg.item(0).align = PicAlign;
}
if ( PicAlt.length > 0 ) {
ctlRg.item(0).alt = PicAlt;
}
}
}
else if (ctlObj.tagName == "TABLE"){
var res = new Array();
res = window.showModalDialog("TblDetails.htm", "width=" + ctlObj.width + " border=" + ctlObj.border, "dialogWidth: 450px; dialogHeight: 300px; font-family: Verdana, Arial; font-size: 8pt;")
if (res != null) {
TblWidth = res["TblWidth"];
TblBorder = res["TblBorder"];

if (TblWidth.length > 0) {
ctlObj.width = TblWidth;
}

if (TblBorder.length > 0 ) {
ctlObj.border = TblBorder;
}
}
}
else {
alert (ctlObj.tagName);
}
}
}
} else {
alert ("Не работает в режиме HTML");
}
}


Желаю успехов!
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.