Constant cells in editor ignoring key and action maps.

Hi, I have an editor definition as shown below.

There are two refNodeList celles for two children entities and factDemos.

I would like the editor to add a new entity to enities when the curson is on the empty constant cell.

The way the editor behaves is quite strange:

  • When the cursor is on the empty constant cell and I pres Enter, a new factDemo is added to the factDemo list (the bottom one)
  • When the cursor is on the Facts constant cell and I press Enter (at the start of the constant), a new entity is added to the entities list at the top.

That behavior is the wrong way around:  the bottom constant adds an element to the toplist and the top constant to the bottom list.

I tried to add an Action map,  a Key map  to the empty constant,  but they aren't even triggered. I also tried to attach a Replace menu to the empty constant cell, but this is never called either.

As soon as I put a character in the empty constant,the Enter key will add to the toplist,  but even then all key maps, actions maps are ignored.

As far as I can see kay maps and action maps don't seem to work on constant cells, which makes it impossible to fine tune the editor behavior.

SI this a known issue?  Or ami I doing something wrong?

 

Regards, Jos

 

6 comments
Comment actions Permalink
Official comment

Dear Jos,

Please try the new 2018.2 version https://www.jetbrains.com/mps/download/

In this version one of the problems is solved: when you stay on the Facts constant cell and press Enter, the new factDemo will be added.

Unfortunately for the second problem, the solution is tricky

When you stay on the constant empty cell, MPS thinks you stay on the end of the cell and tries to find the next collection cell with the children, so it adds the new factDemo child.

The workaround is the following: set the text of the constant cell to " " (just space) and add the style of "last-position-allowed:false" to the constant cell.

This will let MPS think that the caret stays at the start of the cell right after the entities collection, so it will add the child to this collection.

We will make the behavior of pressing Enter more clear and overridable in the future releases.

Also, remember that you can always press shift+Enter and that will force MPS to add the child before the caret

 

 

Comment actions Permalink

Hi Jos, we have struggled with behavior like this rather often. I don't have a solution for you other than working around these default behaviors. Not saying there isn't a solution, I just haven't found a satisfying one. Well, at least for the first issue I could offer you a way, but it is a bit counter-intuitive and it is expensive to make your editor consistent.

So, instead of having the constant in the "Root" editor as in your example, you can add it to the "Entity" editor, like so (my Entity just has a name in this example):

So the constant is rendered after your last element in your entities list. Pressing "Enter" there will add an item "after" the last item, but it will look like it is inserted "before" to the user. Notice that, if you have a list like so, however, pressing "Enter" at position 0 of any entity, will insert an item "before" the current one:

This, you could, however, actually influence via action map, if you want to: 
 

1
Comment actions Permalink

Perhaps making the constant cell editable will help.

Vaclav

0
Comment actions Permalink

Hi Vaclav,  tried this already,  but it does not make any difference.

0
Comment actions Permalink

Hi Robert,

I can see how this workaround should work,  will try it in my editor.

Jos

0
Comment actions Permalink

Hi Robert,

I can see how this workaround should work,  will try it in my editor.

Jos

0

Please sign in to leave a comment.