delagoutte Posted August 11, 2022 Share Posted August 11, 2022 if i do a right click on the title of tabsheet i would like display a unipopupmenu. how can i do this? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 11, 2022 Share Posted August 11, 2022 2 hours ago, delagoutte said: if i do a right click on the title of tabsheet i would like display a unipopupmenu. how can i do this? For example: 1. UniPageControl1.ClientEvents.ExtEvents -> function boxready(sender, width, height, eOpts) { var tab = sender; tab.getEl().on('contextmenu', function(e, target, options) { var totalOffsetX = target.offsetLeft + 20; var totalOffsetY = target.offsetTop + 20; ajaxRequest(tab, 'contextmenu', ['tabIndx='+tab.tabPanel.tabBar.getRefItems().findIndex(item => item.id === target.getAttribute('data-componentid')), 'x='+totalOffsetX, 'y='+totalOffsetY]); }, tab.getEl(), { preventDefault: true, delegate: '.x-tab' }); } 2. UniPageControl1.OnAjaxEvent -> procedure TMainForm.UniPageControl1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'contextmenu' then begin with (Sender as TUniPageControl) do CustomAttribs.Values['contextTab'] := Pages[Params.Values['tabIndx'].ToInteger()].Caption; UniPopupMenu1.Popup(Params.Values['x'].ToInteger(), Params.Values['y'].ToInteger(), Sender); end; end; 3. UniPopupMenu1 -> item GetTabTitle 4. procedure TMainForm.GetTabTitle1Click(Sender: TObject); begin ShowMessage(UniPageControl1.CustomAttribs.Values['contextTab']); end; 1 Quote Link to comment Share on other sites More sharing options...
delagoutte Posted August 12, 2022 Author Share Posted August 12, 2022 thank you it works perfectly 1 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.