So, after some experimentation, I solve the solution. Here is what I did. I created a function that returned the selected text from the document:
function getSelectedText() { return document.selection.createRangeCollection()[0].text; }
From here, I was able to adapt the CupOfTea696 solution to use jQuery to bind events like this:
$("#input").on("click change keyup select", function (event) { if(getSelectedText().length < 1) hideAppBar(); else showAppBar(); });
So, I basically check the length of the selected text and based on this show or hide the context menu.
I still have a blur problem, but this is more likely due to the click event fired in AppBar rather than the above solution. I also tested this only on Win8, so Iβm not sure if this will be a valid web solution, but I donβt understand why this will not work.
source share