General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
CloseTab Event
Posted by: Slayer
Date: June 22, 2009 03:09AM

Hey people, I need to know how to trap the last closed Tab. With $OnCloseTab, the code works fine if there are two or more Tabs. But the last one doesn't seem to trigger the CloseTab Event.
All help is welcome, (links, code, workarounds). Thanks

Options: ReplyQuote
Re: CloseTab Event
Posted by: JamesD
Date: June 22, 2009 03:35AM

If you do not have two then you don't have tabs. Maybe then the last one will be "OnCloseWindow".

Options: ReplyQuote
Re: CloseTab Event
Posted by: Slayer
Date: June 22, 2009 03:56AM

Yes, I've tried $OnCloseWindow already, but it gets triggered only when you close KM.
The last Tab is not a Tab? I need to catch that one.sad smiley
I will see what can I do...

Options: ReplyQuote
Re: CloseTab Event
Posted by: Slayer
Date: June 22, 2009 04:15AM

BTW: In the variable $TabNumber, the last tab counts. It is '1', so there is a Tab.:s

Options: ReplyQuote
Re: CloseTab Event
Posted by: JamesD
Date: June 22, 2009 10:25AM

OK, if $TabNumber is 1 and you need to know when it is closed then closing that tab is closing KM. Could you possibly just work from knowledge that all but one tab have been closed? What kind of action do you need to have happen on closing the last tab?

Options: ReplyQuote
Re: CloseTab Event
Posted by: JamesD
Date: June 22, 2009 12:20PM

I find it hard to think of tabs in the singular. I don't have the tab bar display when there is only one tab. Here is some code that seems to work for catching the close on each tab. Hope it helps.

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- OCT_test.kmm
# --------------------------------------------------------------------------------

_OCT_test_close_tab{
alert("Closed tab - tabs remaining " . $TabNumber-1, "Action is close a tab", INFO);
}

_OCT_test_close_last_tab{
$kTabs?alert("Closed tab - tabs remaining " . $TabNumber-1, "Action is close the last tab", INFO):0;
}

_OCT_test_tab_count{
alert( $TabNumber, "Current tab count", INFO);
}

_OCT_test_BuildMenu{
$kTabs?setmenu("&File",macro,"OCT test",_OCT_test_tab_count,-1):0;
}

$OnInit=$OnInit."_OCT_test_BuildMenu;";
$OnCloseTab=$OnCloseTab."_OCT_test_close_tab;";
$OnCloseWindow=$OnCloseWindow."_OCT_test_close_last_tab;";
$macroModules=$macroModules."OCT_test;";


Options: ReplyQuote
Re: CloseTab Event
Posted by: desga2
Date: June 22, 2009 03:56PM

Quote
Slayer
Yes, I've tried $OnCloseWindow already, but it gets triggered only when you close KM.
The last Tab is not a Tab? I need to catch that one.sad smiley
I will see what can I do...

Are you tried something more easy as $URL ???

K-Meleon in Spanish

Options: ReplyQuote
Re: CloseTab Event
Posted by: Slayer
Date: June 22, 2009 04:44PM

Yes, I'm retrieving the $URL from the closed Tab.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.