question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Arrays, Enter and Intuition

See original GitHub issue

Describe the bug I can’t call it a bug, but I did test it on a few people, and I believe the current behaviour is too complicated and unintuitive for most users. Basically, when a user hits enter, they are marking the “end” of an input.

Perhaps instead of using the <enter> key to make new rows in an array, we should just go with the latex shortcuts that most people editing matrices will be familiar with (&) and (\\). Alternatively, the matlab shortcuts also seem like a good fit (, for new column and ; for new row).

I noticed a few confused faces on some of the examples below:

To Reproduce In a mathlive document, type s i n ( 3 <enter> This will create an array inside of sin

image

Expected behavior Pressing enter at that location should have removed focus from the editor. I propose that:

Enter should always commit the current document whether or not the input is valid

Environment Any (but I’m on a mac)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
arnogcommented, Oct 11, 2020

Added onCommit listener to mf.options. This listener is invoked when the user presses Enter or Return key, or when the field loses focus and its value has changed since it acquired it.

In addition, a change event is triggered when using a MathfieldElement.

The event previously named change has been renamed to input.

This mimics the behavior of <input> and <textarea> elements.

Changed the keyboard shortcuts to add columns and rows:

Shortcut Command
ctrl/cmd + Return/Enter addRowAfter
ctrl/cmd + shift + Return/Enter addRowBefore
ctrl/cmd + ; addRowAfter
ctrl/cmd + shift + ; addRowBefore
ctrl/cmd + , addColumnAfter
ctrl/cmd + shift + , addColumnBefore

Note that Enter/Return no longer create a matrix/vector when inside a parenthesized expression. Use ctrl/cmd + Return/Enter instead.

Added a commit command to programmatically trigger the onCommit listener change event.

0reactions
saivancommented, Jul 6, 2019

I think the comma and semicolon are pretty common. That would be my suggestion :p

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Arrays in JavaScript | DigitalOcean
In this tutorial, we will learn how to create arrays; how they are indexed; how to add, modify, remove, or access items in...
Read more >
What is the real intuition behind using stack in finding Next ...
I was asked of a question in my interview which was returning ans array in which, ans[i] = next greater element of A[i]...
Read more >
Arrays in Fortran
Using its array syntax, vectors and matrices can be initialized and used in a very intuitive way. Dynamic memory allocation enables sizing your...
Read more >
Intuition for Kadane's Algorithm/ Maximum sub-array sum |
Maximum sub -array sum is one of the most popular questions in computer science algorithms. There are many ways to do it.
Read more >
Valid mountain array - Intuition + Dry run + Live code - (Java)
Given an array of integers arr, return true if and only if it is a valid mountain array.Example 1: Input : arr =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found