Jump to content

auto width unipopupmenu


SayeyeZohor

Recommended Posts

1 hour ago, SayeyeZohor said:

how to auto width unipopupmenu change  to parent unimenubutton?

One of the possible solutions for now:

UniMenuButton1.ClientEvents.ExtEvents -> 

function menushow(sender, menu, eOpts)
{
    var me=sender.menu;
    if (me) {
        me.setWidth(sender.getWidth());
        me.items.each(function(item){
            item.setMinWidth(sender.getWidth()-6)
        });
    }
}

 

  • Like 1
Link to comment
Share on other sites

33 minutes ago, Sherzod said:

One of the possible solutions for now:

UniMenuButton1.ClientEvents.ExtEvents -> 


function menushow(sender, menu, eOpts)
{
    var me=sender.menu;
    if (me) {
        me.setWidth(sender.getWidth());
        me.items.each(function(item){
            item.setMinWidth(sender.getWidth()-6)
        });
    }
}

 

It is displayed the first time and then corrected...

image.png.9ac742039bcafd116e0e9b8ac5c00324.png

 

and then fix

image.png.907d29b3322de91db83dbcb5900820e2.png

 

function menushow(sender, menu, eOpts)  --- > menubeforeshow ? ???????????

 

Link to comment
Share on other sites

Can you try another solution?

1. Remove:

function menushow(sender, menu, eOpts)
{
    /*var me=sender.menu;
    if (me) {
        me.setWidth(sender.getWidth());
        me.items.each(function(item){
            item.setMinWidth(sender.getWidth()-6)
        });
    }*/
}

2. 

type
  TXPopupMenu = class(TUniPopupMenu)

  end;

3. UniFormReady event:

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  with TXPopupMenu(UniPopupMenu1).MenuControl.JSInterface do
    JSConfig('minWidth', [UniMenuButton1.Width-6]);
 
end;

 

  • Like 2
Link to comment
Share on other sites

7 minutes ago, Sherzod said:

Can you try another solution?

1. Remove:


function menushow(sender, menu, eOpts)
{
    /*var me=sender.menu;
    if (me) {
        me.setWidth(sender.getWidth());
        me.items.each(function(item){
            item.setMinWidth(sender.getWidth()-6)
        });
    }*/
}

2. 


type
  TXPopupMenu = class(TUniPopupMenu)

  end;

3. UniFormReady event:


procedure TMainForm.UniFormReady(Sender: TObject);
begin
  with TXPopupMenu(UniPopupMenu1).MenuControl.JSInterface do
    JSConfig('minWidth', [UniMenuButton1.Width-6]);
 
end;

 

tnxxxxxxxxxxxxxxxxx

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...