1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-05 02:34:07 +02:00

Add support for back/forward mouse buttons

This commit is contained in:
chylex 2016-05-10 13:31:18 +02:00
parent a1365a98c0
commit ddec715dda
2 changed files with 55 additions and 2 deletions

View File

@ -169,6 +169,15 @@ private void trayIcon_ClickClose(object sender, EventArgs e){
Close();
}
protected override void WndProc(ref Message m){
if (isLoaded && m.Msg == 0x210 && (m.WParam.ToInt32() & 0xFFFF) == 0x020B){ // WM_PARENTNOTIFY, WM_XBUTTONDOWN
browser.ExecuteScriptAsync("TDGF_onMouseClickExtra",(m.WParam.ToInt32() >> 16) & 0xFFFF);
return;
}
base.WndProc(ref m);
}
// callback handlers
public void OpenSettings(){

View File

@ -4,6 +4,16 @@
//
var isInitialized = false;
//
// Variable: Current highlighted column jQuery object.
//
var highlightedColumnEle;
//
// Variable: Currently highlighted tweet jQuery object.
//
var highlightedTweetEle;
//
// Function: Initializes TweetD*ck events. Called after the website app is loaded.
//
@ -295,7 +305,19 @@
});
//
// Block: Copy tweet address.
// Block: Update highlighted column
//
app.delegate("section","mouseenter mouseleave",function(e){
if (e.type === "mouseenter"){
highlightedColumnEle = $(this);
}
else if (e.type === "mouseleave"){
highlightedColumnEle = null;
}
});
//
// Block: Copy tweet address and update highlighted tweet.
//
(function(){
var lastTweet = "";
@ -307,12 +329,15 @@
}
};
$(document.body).delegate("article.js-stream-item","mouseenter mouseleave",function(e){
app.delegate("article.js-stream-item","mouseenter mouseleave",function(e){
if (e.type === "mouseenter"){
highlightedTweetEle = $(this);
var link = $(this).find("time").first().children("a").first();
updateHighlightedTweet(link.length > 0 ? link.attr("href") : "");
}
else if (e.type === "mouseleave"){
highlightedTweetEle = null;
updateHighlightedTweet("");
}
});
@ -390,6 +415,25 @@
};
})();
//
// Block: Support for extra mouse buttons
//
window.TDGF_onMouseClickExtra = function(button){
if (button === 1){ // back button
if (highlightedColumnEle && highlightedColumnEle.closest(".js-column").is(".is-shifted-1")){
highlightedColumnEle.find(".js-column-back").first().click();
}
else{
$(".js-column-back").click();
}
}
else if (button === 2){ // forward button
if (highlightedTweetEle){
highlightedTweetEle.children().first().click();
}
}
};
//
// Block: Inject custom CSS and layout into the page.
//