Forum Home Login Register Search FAQ
Author Topic: UltraWebMenu and Popup Position (x,y)
Luke T. Gatchell UltraWebMenu and Popup Position (x,y)
on 2004-01-06 (EDT)
Ok, I just recently purchased NetAdvantage and I've been
looking at a way to generate a popup menu when I click on
a button. What I'd like to do is position the popup menu just
below the button that I click, rather than have it show up at
the mouse click position.

Two questions:

1. The Infragistics documentation indicates I can pass x,y as
additional parameters to igmenu_showMenu(), but it doesn't
seem to work, and when I look at the javascript source, I don't
see that ability either (unless I'm looking in the wrong place). Is
this possible, or not? And what type should these parameters be?

2. As an aside, in order to position this menu, I'm trying to get
the x,y position of the button (which is an asp:button). I can
extract that by getting the "style" attribute, then parsing it to find
"TOP" and "LEFT". I was just wondering if anyone knows a
better way. It seems strange that ASP.NET would expose
the height and width, but not those two properties.

Here's the code clip of what I'm doing. It works fine if I leave the
x,y off the function call.

-----
private void Page_Load(object sender, System.EventArgs e)
{
     Put user code to initialize the page here
    int startPos, endPos;

    startPos = Button1.Attributes["style"].IndexOf("TOP:")+4;
    endPos = Button1.Attributes["style"].IndexOf("px", startPos);
    int top =
Convert.ToInt32(Button1.Attributes["style"].Substring(startPos, endPos -
startPos));
    int y = top + Convert.ToInt32(Button1.Height.Value);

    startPos = Button1.Attributes["style"].IndexOf("LEFT:")+5;
    endPos = Button1.Attributes["style"].IndexOf("px", startPos);
    int x = Convert.ToInt32(Button1.Attributes["style"].Substring(startPos,
endPos - startPos));

    Button1.Attributes["onclick"] =
"javascript:igmenu_showMenu('UltraWebMenu2', event, x, y); return false;";
}
-----

Any help would be appreciated. Thanks!

Luke



Message was originally posted to infragistics.dotnet.webmenu
Don (Infragistics) Re: UltraWebMenu and Popup Position (x,y)
on 2004-01-06 (EDT)
Hi Luke,

The trouble your having stems from the way you are passing, (or think you
are passing) the x and y values.
You are only passing a string to the Button1.onclick attribute.  You could
do something like this:
Button1.Attributes["onclick"] =
 "javascript:igmenu_showMenu('UltraWebMenu2', event, " + x.ToString() + ","
+ y.ToString() + "); return false;";

but that still wouldn't get the menu to appear below the button.  I would
suggest setting up a javascript function that gets called by the onclick
event and do some dhtml calculations there, like so:

Button1.Attributes["onclick"] =
 "javascript:MyshowMenu('UltraWebMenu2');"

(In aspx file)
<script language=javascript>

function MyShowMenu(menuName) {
    var button = event.srcElement;
    var x = button.offsetLeft + button.offsetWidth;
    var y = button.offsetTop + button.offsetHeight;
    igmenu_showMenu(menuName, event, x, y); return false;"
}


-Don
Infragistics Web Team


"Luke T. Gatchell" <ltgatchell@hotmail.com> wrote in message
news:3ffae157@news.shersoft.com...
> Ok, I just recently purchased NetAdvantage and I've been
> looking at a way to generate a popup menu when I click on
> a button. What I'd like to do is position the popup menu just
> below the button that I click, rather than have it show up at
> the mouse click position.
>
> Two questions:
>
> 1. The Infragistics documentation indicates I can pass x,y as
> additional parameters to igmenu_showMenu(), but it doesn't
> seem to work, and when I look at the javascript source, I don't
> see that ability either (unless I'm looking in the wrong place). Is
> this possible, or not? And what type should these parameters be?
>
> 2. As an aside, in order to position this menu, I'm trying to get
> the x,y position of the button (which is an asp:button). I can
> extract that by getting the "style" attribute, then parsing it to find
> "TOP" and "LEFT". I was just wondering if anyone knows a
> better way. It seems strange that ASP.NET would expose
> the height and width, but not those two properties.
>
> Here's the code clip of what I'm doing. It works fine if I leave the
> x,y off the function call.
>
> -----
> private void Page_Load(object sender, System.EventArgs e)
> {
>      Put user code to initialize the page here
>     int startPos, endPos;
>
>     startPos = Button1.Attributes["style"].IndexOf("TOP:")+4;
>     endPos = Button1.Attributes["style"].IndexOf("px", startPos);
>     int top =
> Convert.ToInt32(Button1.Attributes["style"].Substring(startPos, endPos -
> startPos));
>     int y = top + Convert.ToInt32(Button1.Height.Value);
>
>     startPos = Button1.Attributes["style"].IndexOf("LEFT:")+5;
>     endPos = Button1.Attributes["style"].IndexOf("px", startPos);
>     int x =
Convert.ToInt32(Button1.Attributes["style"].Substring(startPos,
> endPos - startPos));
>
>     Button1.Attributes["onclick"] =
> "javascript:igmenu_showMenu('UltraWebMenu2', event, x, y); return false;";
> }
> -----
>
> Any help would be appreciated. Thanks!
>
> Luke
>
>



Message was originally posted to infragistics.dotnet.webmenu
Luke T. Gatchell Re: UltraWebMenu and Popup Position (x,y)
on 2004-01-09 (EDT)
Don,

Thanks for your reply. Already I can't believe I tried to do
what I just posted.  After playing with things a few more
days, interacting between the javascript and the C# that
underlies each .aspx page has become a lot clearer. And
your recommendation to move it to a function is obviously
the "right way" to do things.

And thanks for responding so quickly!

Luke


"Don (Infragistics)" <productmanager@infragistics.com> wrote in message
news:3ffb3234$1@news.shersoft.com...
> Hi Luke,
>
> The trouble your having stems from the way you are passing, (or think you
> are passing) the x and y values.
> You are only passing a string to the Button1.onclick attribute.  You could
> do something like this:
> Button1.Attributes["onclick"] =
>  "javascript:igmenu_showMenu('UltraWebMenu2', event, " + x.ToString() +
","
> + y.ToString() + "); return false;";
>
> but that still wouldn't get the menu to appear below the button.  I would
> suggest setting up a javascript function that gets called by the onclick
> event and do some dhtml calculations there, like so:
>
> Button1.Attributes["onclick"] =
>  "javascript:MyshowMenu('UltraWebMenu2');"
>
> (In aspx file)
> <script language=javascript>
>
> function MyShowMenu(menuName) {
>     var button = event.srcElement;
>     var x = button.offsetLeft + button.offsetWidth;
>     var y = button.offsetTop + button.offsetHeight;
>     igmenu_showMenu(menuName, event, x, y); return false;"
> }
>
>
> -Don
> Infragistics Web Team



Message was originally posted to infragistics.dotnet.webmenu
Carlos Netdev Re: UltraWebMenu and Popup Position (x,y)
on 2006-11-21 (EDT)
I have one UltraWebTree with one UltraWebMenu pop-up. At the top of the 
page, the position of the menu is ok, but if I scroll the page, the menu 
also show at the top of the page making invisible for the user.
I try many codes but does not work. The last based on above is:
In the firefox anyone stop the menu work.

nodeClicked = igtree_getNodeById(nodeId);
var x = nodeClicked.offsetLeft + nodeClicked.offsetWidth;
var y = nodeClicked.offsetTop + nodeClicked.offsetHeight;
igmenu_showMenu('PopUpMenu', event, x, y);
return true;

I tried to with the mouse position with:

var IE = document.all?true:false
function getMouseXY(e) {
  if (IE) {  grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {   grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true
}

Sorry for my English.
Ricardo


"Luke T. Gatchell" <ltgatchell@hotmail.com> wrote in message 
news:5207_3ffee0a6$1@news.shersoft.com...
>Don,
>
>Thanks for your reply. Already I can't believe I tried to do
>what I just posted.  After playing with things a few more
>days, interacting between the javascript and the C# that
>underlies each .aspx page has become a lot clearer. And
>your recommendation to move it to a function is obviously
>the "right way" to do things.
>
>And thanks for responding so quickly!
>
>Luke
>
>
>"Don (Infragistics)" <productmanager@infragistics.com> wrote in message
>news:3ffb3234$1@news.shersoft.com...
>> Hi Luke,
>>
>> The trouble your having stems from the way you are passing, (or think you
>> are passing) the x and y values.
>> You are only passing a string to the Button1.onclick attribute.  You could
>> do something like this:
>> Button1.Attributes["onclick"] =
>>  "javascript:igmenu_showMenu('UltraWebMenu2', event, " + x.ToString() +
>","
>> + y.ToString() + "); return false;";
>>
>> but that still wouldn't get the menu to appear below the button.  I would
>> suggest setting up a javascript function that gets called by the onclick
>> event and do some dhtml calculations there, like so:
>>
>> Button1.Attributes["onclick"] =
>>  "javascript:MyshowMenu('UltraWebMenu2');"
>>
>> (In aspx file)
>> <script language=javascript>
>>
>> function MyShowMenu(menuName) {
>>     var button = event.srcElement;
>>     var x = button.offsetLeft + button.offsetWidth;
>>     var y = button.offsetTop + button.offsetHeight;
>>     igmenu_showMenu(menuName, event, x, y); return false;"
>> }
>>
>>
>> -Don
>> Infragistics Web Team
>
>
>
>Message was originally posted to infragistics.dotnet.webmenu