Notifications
Clear all
[Closed] Detecting when user right-clicks dotnet tab
Aug 31, 2008 9:56 pm
I’m trying to detect when the user right-clicks on a dotnet tab control.
More specifically, I just need to know how to find out which tab is under the mouse at a given time. Evidently the tabs don’t have a hitTest() method like the treeview does.
Has anyone done this before?
Thanks!
2 Replies
Aug 31, 2008 9:56 pm
Try this:
try(destroyDialog ro_test)catch()
rollout ro_test "test"
(
dotNetControl tabs "TabControl" width:150 height:200 pos:[0,0]
on tabs click sender args do (
-- If right click:
if dotnet.CompareEnums args.Button (dotNetClass "System.Windows.Forms.MouseButtons").Right then (
-- GetChildAtPoint should have worked, but only returns undefined for some reason
print (sender.GetChildAtPoint args.Location)
-- Instead, loop through the tabs and see which one occupies this area.
local tab = undefined
for i = 0 to (tabs.TabPages.Count - 1) where tab == undefined do (
local tabRect = tabs.GetTabRect i
if tabRect.Contains args.Location then
tab = tabs.TabPages.Item[i]
)
if tab != undefined then
print tab.Text
)
)
on ro_test open do (
local tab1 = dotNetObject "TabPage" "Tab 1"
local tab2 = dotNetObject "TabPage" "Tab 2"
tabs.TabPages.Add tab1
tabs.TabPages.Add tab2
)
) -- end of ro_test
createDialog ro_test
hOpe this helps,
o