Jira escape button behaviour - events

I am currently working with Jira and stumbled on a problem. If on the browse page of an issue and editing a textfield, pressing escape discards all changes. Doing the same editing a comment field, doesn't discard changes on the comment. What I really want is that changes will be saved when pressing escape and losing focus on editing the field content. The same that happens if you click in an empty area.
Of course I am not the only one searching for a solution to this problem:
https://jira.atlassian.com/browse/JRA-36670
https://jira.atlassian.com/browse/JRA-41814
Now I am not here to discuss the meaning of the escape button. There are several reasons for the behaviour i wish (start with reading the comments on the first link).
Is there any way to edit Keyevent handling of jira? Or overwrite event behaviour of standard fields? Adding events via browser plugins or similar doesn't help as the content is already lost then.
I hope there is some elegant solution out there as I am not the only searching for one. Any suggestions?

Athlassian really did it with the Esc-behavior. It costs people nerves and money. Esc shouldn't save anything IMHO but it should at least offer you the possibility of retreiving the lost work. Jira-Description might get realy big and if you don't save you lose your temper and resources.
There is a nice workaround though. I found it in Jira-Development Jira :)
The workaround:
Install this extension
Open any of your JIRA pages, click the "CJS" icon in the toolbar
Paste this snippet
document.addEventListener("keydown",function(e)
{
var charCode = e.charCode || e.keyCode || e.which;
if (charCode == 27)
{
alert("Please do not press escape.")
}
});
document.addEventListener("keyup",function(e){
var charCode = e.charCode || e.keyCode || e.which;
if (charCode == 27){
alert("Please do not press escape.")
}
});
Now you will get an alert every time the escape key is pressed and the content will be preserved.

I don't think you should save edits when pressing escape. Its pretty intuitive to abort an action by pressing esc. You will confuse your users. They will make changes to their issues, they didn't wanted to do.
This behavior is discussed here:
https://jira.atlassian.com/browse/JRA-36670
You are right - Comments are saved after pressing escape, but this behavior might change very soon: https://jira.atlassian.com/browse/JRA-41814
What you can do:
You could write your own plugin, and attach a javascript event
listener to your issue view.
When you press Esc, copy the content of the description field.
Use JIRA rest services to update your issue wit the text you copied from the description field.
But as I said - this is messy and you should not do it.

Related

How to insert text into an Ace Editor instance as a comment

I am building a website where I want to allow people to code in almost any language that the Ace editor supports. Right now I have it redirect if they try to load a language that either isn't supported by Ace, or that I didn't list in my supported languages. I only have a few languages that I allow to run (because I haven't got others to work or don't know how to), and for all those other languages that aren't run-supported, I want to load the Ace editor with a note saying that the language they loaded isn't supported for running, but I want it to be a comment in that language.
I tried inserting the text using editor.setValue([message], -1). Then set the focus on the editor using editor.focus(). Then I select all the text with editor.selectAll(). And then use the editor.toggleCommentLines() to make it a comment. For some reason this doesn't work, and I am not sure why.
I know that I could just look up how to write comment in each of the languages that I am allowing, and then convert the message into a comment before inserting it into the editor, but I want an easier way if possible.
Is there an easier way to do it? Or should I just do what I said that I could?
Since I answered my own question, I want to ask another to see if anyone has the answer for this:
When in the Ace editor you can press CTRL+/ to toggle line comments. But if you press CTRL+SHIFT+/ it will toggle multiline comments. I don't see a function for this in the Ace editor documentation but because it works with a keyboard shortcut, there must be a way to do it programmatically, right?
If someone could figure this out, that would be great!
a user found it! See his comment to see the answer to this part.
I was trying a few more things, and one of them was doing a setTimeout on the editor.toggleCommentLines(), and that worked. The timeout worked best if I used 150ms or higher (I started with 2000 just to see if it worked at all, and then slowly moved down).
So the following code works to automatically insert a message and comment it out:
const editor = ace.edit([element]);
editor.setValue([message], 0); // You can also leave the second parameter blank, 0 is the default which automatically selects all.
setTimeout(() => {
editor.toggleCommentLines();
}, 150); // 150ms or more works best
You may also notice that this method clears out 2 methods that I was previously using. There are two reasons for this:
When using 0 instead of -1 for the second parameter of editor.setValue() it selects all the text.
Because we are using the editor variable, the editor doesn't need to be in "focus".

Update Gui without pressing submit in AHK

So I bet the has already been covered but I couldn't find it, so if you know where the answer is, simply point me in the right direction!
I have a GUI with two radio check boxes, and I would like to show/hide some commands based on which radio is selected. However, I would prefer not to have to create a new GUI, or have to click the Submit button to do so. Is there a way to trigger guicontrol without submitting the gui?
Thanks!
Paul
Ok, so I figured out how to accomplish what I'm trying to do, and so I'm posting it here for posterity sake! ;)
I realized that I could use GUI, Submit without closing the form if I appended it with nohide. So I created a glabel for both radio buttons, so when either one is selected they activate a subroutine which submits the form (without hiding it), and does whatever actions I want it to, such as show more commands, or insert text.
Paul

Slickgrid cell text selection does not work properly in Chrome or Firefox

I have set enableTextSelectionOnCells according to SlickGrid and Text Selection.
I am not really happy about it.
Cell text gets selected with a bad behaviour. Sometimes as soon as selection is done, the selection disappears. Only on rare occasions does it work.
Has anyone faced this issue?
I have tried this on Firefox and Chrome.
to reproduce:
git clone git#github.com:mleibman/SlickGrid.git
go to examples folder
edit the example1-simple.html
Add enableTextSelectionOnCells: true in options
Open example1-simple.html in FF/Chrome
Try selecting a cell value
FYI, I am running on Ubuntu if it should make any difference.
This problem is already solved on Github. You just have to modify slick.gird.js. Around line number 2270, you just have to add " options.editable && ". Hope this help.
if (!currentEditor) {
// if this click resulted in some cell child node getting focus,
// don't steal it back - keyboard events will still bubble up
// IE9+ seems to default DIVs to tabIndex=0 instead of -1, so check for cell clicks directly.
if (options.editable && e.target != document.activeElement || $(e.target).hasClass("slick-cell")) {
setFocus();
}
}

Programatically triggering tab key functionality in a VB.Net windows application

How can I programatically trigger the tab key functionality in a VB.Net windows application?
Currently in my application I am using one splitter when I press the tab key, and the focus is moving in the right order.
However I need to use arrow keys to move the focus to next controls, in the same way that the focus is going when the user presses the tab keys.
Thanks in Advance
You can simulate the SendKeys.Send(string) method (in the Systems.Windows.Forms namespace). To simulate a tab keypress you would call SendKeys.Send("{TAB}").
To see all the key codes, check out http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
Better late, than never, since i found this post looking for a solution to a similar problem.
Windows Form type has ContainerControl somewhere in its chain of inheritance and that has a method ProcessTabKey(Boolean trueForForward) . It does exactly what you need, inside your form instance this.ProcessTabKey(true) will move focus forward along the tab index and this.ProcessTabKey(false) will move it backward.
Very simple code
Write Down this in KeyDown Event of Datagridview
If e.KeyCode = Keys.Enter Then
' Your code here
SendKeys.Send("{TAB}")
e.Handled = True
End If

Janus GridEX Problem

It's a longshot that anyone can help with this, but here goes. I inherited a VB6 app with a Janus GridEX control. It iterates through records, and is editable. Problem is, if I edit a cell and hit the button to go to the next record, the change is applied to the next record, not the one I was editing. It's like, I need it to finish up the edit before going to the next record. I've had this sort of problem before in VC++, and sometimes you have to "KillFocus" on the control you're on or something. I just don't know what to do here. I tried sending a carriage return, since if you return out of the edit cell, it works, but sending a carriage return manually doesn't work. What's the secret?
Is your grid bound or unbound?
It's hard to tell from your description, but I imagine that if your are having this problem then it's probably bound.
As the other answer asked, is the button the RecordNavigator that is built into the control or is it a separate button? The reason I bring this up again, is that I have seen issues in the VB6 applications I support where a toolbar will often intercept and interfere with how the JanusGrid should work.
To get around this limitation, I have added the following code in the click handler of any toolbars where there is also a JanusGrid control on the form.
If jsgxYourGridName.EditMode = jgexEditModeOn Then jsgxYourGridName.Update
This way any changes are immediately applied to the current row.
If this does not help, then I have also seen problems where the recordset that is bound to the grid gets out of sync with the internal recordset in the grid. You can check this by comparing the bookmark of the grid to the bookmark of the recordset.
Ie. mrsYourRecordset.Bookmark = jsgxYourGrid.ADORecordset.Bookmark
At one point I may have also used something like this.
jsgxYourGrid.ADORecordset.Bookmark = jsgxYourGrid.RowBookmark(jsgxYourGrid.RowIndex(jsgxYourGrid.Row))
Finally you can try setting a breakpoint in the BeforeUpdate, RowColChange and/or AfterColUpdate events of the grid, to see what record the grid is really on when clicking on the button.
It depends whether the button is internal to Janus GridEX or not. If it internal then just about the only thing you can do is look at the events the control exposes to see if there a sequence that can let you know that this problem occurs. Then you can try to take corrective action by restoring the row you moved to and put the edit in the row you left.
If the button is external to Janus then you can use the debug mode to trace sequence of statement that control the transfer of focus to the next row. It could be something out of order or a side effect of the particular sequence of commands. I have run into both with different controls.
Remember that you can edit while in debug mode so you can try different approaches and test until you find one that works.

Resources