MSMK Posted November 30, 2023 Share Posted November 30, 2023 Еще раз салам. Столкнулся с такой проблемой, при создании в рантайме компонента UniPopupMenu, задаю ему стиль CSS with TExtPopup(UniPopupMenu).MenuControl.JSInterface do begin JSConfig('cls', ['custom-menu-item']); end; при инициализации выходит ошибка: тестовый пример приложил testMenuButton.zip Quote Link to comment Share on other sites More sharing options...
MSMK Posted November 30, 2023 Author Share Posted November 30, 2023 top Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 30, 2023 Share Posted November 30, 2023 2 hours ago, =GGG= said: with TExtPopup(UniPopupMenu).MenuControl.JSInterface do begin JSConfig('cls', ['custom-menu-item']); end; Перенесите этот код в событие UniFormReady... Quote Link to comment Share on other sites More sharing options...
MSMK Posted November 30, 2023 Author Share Posted November 30, 2023 20 minutes ago, Sherzod said: Перенесите этот код в событие UniFormReady... Вы меня не поняли. Я так пробовал, все работает. Мне нужно именно когда я создаю объект, в рантайм Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 30, 2023 Share Posted November 30, 2023 11 minutes ago, =GGG= said: Вы меня не понял. Я так пробовал, все работает. Мне нужно именно когда я создаю объект, в рантайм Именно UniPopupMenu? А я не вижу что этот объект создается в runtime. Quote Link to comment Share on other sites More sharing options...
MSMK Posted November 30, 2023 Author Share Posted November 30, 2023 8 minutes ago, Sherzod said: Именно UniPopupMenu? А я не вижу что этот объект создается в runtime. да именно UniPopupMenu. Да я там не создаю в рантайм, но ошибка таже, если делать это в рантайме Quote Link to comment Share on other sites More sharing options...
MSMK Posted November 30, 2023 Author Share Posted November 30, 2023 Just now, =GGG= said: да именно UniPopupMenu. Да я там не создаю в рантайм, но ошибка таже, если делать это в рантайме чт омне тестовый проект запилить для этого? суть то понятно? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 30, 2023 Share Posted November 30, 2023 1 minute ago, =GGG= said: чт омне тестовый проект запилить для этого? Нет. Quote Link to comment Share on other sites More sharing options...
MSMK Posted November 30, 2023 Author Share Posted November 30, 2023 51 minutes ago, Sherzod said: Нет. мне ждать от вас подмоги?)) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 30, 2023 Share Posted November 30, 2023 2 hours ago, =GGG= said: мне ждать от вас подмоги?)) procedure TMainForm.UniFormCreate(Sender: TObject); begin //with TExtPopup(UniPopupMenu).MenuControl.JSInterface do //begin // JSConfig('cls', ['custom-menu-item']); //end; MenuButton := TUniMenuButton.Create(Self); MenuButton.Name := 'btnMenuButton'; MenuButton.Caption := 'Наведи на меня и я покажу тебе меню'; MenuButton.ClientEvents.UniEvents.Values['afterCreate'] := 'function afterCreate(sender)' + '{'+ ' textMetrics = new Ext.util.TextMetrics();'+ ' valWidth = textMetrics.getWidth(sender.text);'+ ' sender.width = valWidth + 30;'+ '}'; MenuButton.ClientEvents.ExtEvents.Values['mouseover'] := 'function mouseover(sender, e, eOpts)'+ '{'+ ' sender.maybeShowMenu();'+ ' sender.menu.setWidth(sender.getWidth());'+ '}'; MenuButton.JSInterface.JSConfig('cls', ['ribbon-menu-btn']); MenuButton.JSInterface.JSAddListener('menushow', 'function(me){me.getMenu().addCls("custom-menu-item")}'); //<------------ MenuButton.DropdownMenu := UniPopupMenu; MenuButton.Parent := pnTools; MenuButton.Visible := True; end; Quote Link to comment Share on other sites More sharing options...
MSMK Posted December 1, 2023 Author Share Posted December 1, 2023 17 hours ago, Sherzod said: procedure TMainForm.UniFormCreate(Sender: TObject); begin //with TExtPopup(UniPopupMenu).MenuControl.JSInterface do //begin // JSConfig('cls', ['custom-menu-item']); //end; MenuButton := TUniMenuButton.Create(Self); MenuButton.Name := 'btnMenuButton'; MenuButton.Caption := 'Наведи на меня и я покажу тебе меню'; MenuButton.ClientEvents.UniEvents.Values['afterCreate'] := 'function afterCreate(sender)' + '{'+ ' textMetrics = new Ext.util.TextMetrics();'+ ' valWidth = textMetrics.getWidth(sender.text);'+ ' sender.width = valWidth + 30;'+ '}'; MenuButton.ClientEvents.ExtEvents.Values['mouseover'] := 'function mouseover(sender, e, eOpts)'+ '{'+ ' sender.maybeShowMenu();'+ ' sender.menu.setWidth(sender.getWidth());'+ '}'; MenuButton.JSInterface.JSConfig('cls', ['ribbon-menu-btn']); MenuButton.JSInterface.JSAddListener('menushow', 'function(me){me.getMenu().addCls("custom-menu-item")}'); //<------------ MenuButton.DropdownMenu := UniPopupMenu; MenuButton.Parent := pnTools; MenuButton.Visible := True; end; спасибо огромное Quote Link to comment Share on other sites More sharing options...
MSMK Posted December 1, 2023 Author Share Posted December 1, 2023 а подскажите еще, как убрать тень у выпадающего меню? Прововал так .custom-menu { box-shadow: none !important;; } не помогло. И еще сделать выпадающее меню белым цветом. Пробовал так .custom-menu-item .x-menu-body-default { background: #fff !important;; padding: 2px; } тоже не помогло Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 1, 2023 Share Posted December 1, 2023 Добрый день, Попробую проанализировать. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 1, 2023 Share Posted December 1, 2023 1 hour ago, =GGG= said: а подскажите еще, как убрать тень у выпадающего меню? Попробуйте: MenuButton.JSInterface.JSAddListener('menushow', 'function(me){Ext.defer(function(){me.getMenu().getEl().shadow.hide()}, 10); me.getMenu().addCls("custom-menu-item")}'); Quote Link to comment Share on other sites More sharing options...
MSMK Posted December 1, 2023 Author Share Posted December 1, 2023 4 hours ago, Sherzod said: Попробуйте: MenuButton.JSInterface.JSAddListener('menushow', 'function(me){Ext.defer(function(){me.getMenu().getEl().shadow.hide()}, 10); me.getMenu().addCls("custom-menu-item")}'); спасибо Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.