81

I've been using a Surface Pro 4, which has a touch screen, but is also a fully-functional Windows 10 computer with a keyboard and trackpad. I often follow links/interact with web pages by touch instead of the trackpad.

When editing a post with a runnable code snippet, tapping the "edit the above snippet" link fails with an alert: "The snippet editor does not support touch devices." Clicking the link, of course, works fine and opens the snippet editor.

I find this pretty annoying, especially because of my habit of tapping links/buttons. Would it be possible for this feature to be a little smarter in detecting touch-only devices, and allow touch on a device like mine? Or perhaps only warn the user (maybe once, and remember?) and let them continue?

7
  • 31
    tfw you see a well-written, well-researched programming question... on meta.
    – BoltClock
    Dec 4, 2016 at 4:33
  • 31
    @BoltClock ...and it's on-topic
    – Nic
    Dec 4, 2016 at 6:28
  • 11
    +1 agreed. But why exactly are touch devices not supported? I have a tablet that I use for stackoverflow-ing and it is really annoying that I can't open the snippet editor, especially when posting questions.
    – Spikatrix
    Dec 5, 2016 at 1:21
  • 6
    It just detects type of event, not type of device. Touchscreens produce special touch events AND mouse events. Now even desktops are "touch devices".. I have 24" touch screen display on my table and this limitation sounds silly. At work we all have touchscreens, because we design touch-aware software... for other desktops. Limited support on mobile - yeah, small screen, different platform , etc. Cutting off a PC user because he tried to use his touchscreen? An example of edge case.. they even went on the road to check if that's actually touch, not mouse click XD Dec 5, 2016 at 1:53
  • 1
    Looks like it's a general error message for "external editors": var k = 'The ' + i + ' editor does not support touch devices.', perhaps they have other types of editors across the network where touch support is harder to implement.
    – user247702
    Dec 5, 2016 at 10:18
  • 5
    @Stijn See UX.SE, where there’s a Flash-based mockup designer.
    – Jed Fox
    Dec 5, 2016 at 12:58
  • 3
    What's more, touchscreen+physical keyboard sounds like a very viable combination, and then you wouldn't have the workaround of "use the touchpad to activate the link".
    – Ben Voigt
    Dec 5, 2016 at 19:29

1 Answer 1

3

As far as I can tell, the snippet editor itself does work just fine on touch devices. The problem is that, as Stijn notes, the SE external editor code simply refuses to run any external editor on touch devices. Presumably, this "feature" was introduced because there are (or were) some external editors enabled on some SE sites that really didn't work properly on touchscreen devices, but at least for the SO snippet editor, the restriction seems misplaced.

If you have a touchscreen device with a browser that has a working JS console, you can try running the following JS code to re-enable the snippet editor button on the current page:

$('body').on('touchstart', '.wmd-snippet-button > span', function () { $(this).off('touchend') })

Alternatively, if your browser supports bookmarklets, you can try creating one with the following URL:

javascript:(function(){$('body').on('touchstart','.wmd-snippet-button>span',function(){$(this).off('touchend')})})()

So far, I have only tested this on the desktop version of Chromium, using its touch event emulation, but at least it seems to work fine there. As a quick demonstration, I used it to create the following test snippet:

console.log("Hello, World!")

In any case, it seems that the inability to use the snippet editor on touch devices is a simple developer oversight that should be fixed.

1
  • 2
    Unfortunately, it seems that the CodeMirror editor used to edit the snippets is indeed buggy on actual touch devices, or at least specifically on my Galaxy S8 with Firefox for Android. It appears to work OK at first, but as soon as you finish typing a complete word and hit space, the entire word disappears. I have no real idea why that happens, but I suspect it's some weird interaction with the on-screen keyboard. :( Mar 7, 2019 at 20:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .