Hi, I need a button item on my form which displays menu when pressed (something like ‘buttonselect’, but without default action). Is there such functionality available, and if not what approach could I use?
Thanks in advance
Hi
I hope i anderstood you right, see the demo (not well styled, but i hope the logic will be suitable)
items.rar (741 KB)
Thanks for the demo.
In yours example you have:
type: "container",
name: "myMenu",
label: "Select Product",
inputWidth: 170,
inputHeight: 27
as menu holder, but can I have a button instead?
And on button click menu shows.
Thanks once more
Here is a real dhtmlxMenu in a form containre. It hasn’ buttons. If you need exactly menu - it will be the same. I just can to recommend you using a simple dhtmlxForm button and by click on it to show contextMenu
dhtmlx.com/docs/products/dht … ntext.html
Something like this
I was thinking of doing something like that.
OnButtonClick show the menu, however I need, for example, bottom left button coordinates so I could call:
showContextMenu(x, y)
How can I get button’s bottom-left coordinates?
It is a JavaScript question, not dhtmlx
stackoverflow.com/questions/8292 … ss-browser
stackoverflow.com/questions/5797 … javascript
Getting button object (sample):
[code]formData = [
{type:‘button’, name:‘btn’, id:‘btn’, value:‘Create Tour’, offsetLeft:20},
{type: ‘newcolumn’, offsetLeft: ‘10px’},
{type:‘button’, name:‘btn2’, id:‘btn2’, value:‘Create r’, offsetLeft:20}
];
form = new dhtmlXForm(“myForm”, formData);
dhtmlXForm.prototype.getButton = function(name){
return this.doWithItem(name, "getButton");
};
dhtmlXForm.prototype.items.button.getButton = function(item){
return item.firstChild;
};
var t = form.getButton("btn2"); // {type:button, name: "btn2"}
var dim = {
x: getAbsoluteLeft( t ),
y: getAbsoluteTop( t ),
w: t.offsetWidth,
h: t.offsetHeight
};
console.log(dim)[/code]
Thanks, works like a charm
Forgot to add, also used:
myMenu.contextAutoHide = false; - disable hiding menu on click
myMenu.contextAutoShow = false; - disable opening menu on right click
Unfortunately I just notice
myMenu.contextAutoShow = false;
(disable opening menu on right click) doesn’t work for me. I believe it’s because form button item (the one that holds my menu) receive ‘onClick()’ event no matter if it’s right or left.
Is there a way I can test if onClick occurred with right mouse click?
Thanks in advance.