Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edit menu when editing text #725

Closed
kopach opened this issue Sep 12, 2017 · 12 comments
Closed

Add edit menu when editing text #725

kopach opened this issue Sep 12, 2017 · 12 comments

Comments

@kopach
Copy link
Contributor

kopach commented Sep 12, 2017

Usually, all the programs which has text input fields - provides standard Edit menu with actions like: Undo, Redo, Copy, Paste, etc.

Also, (probably because of using some kind of standard system library for this) in such kind on Edit menu on Mac there is Emoji & Symbols option. I often use non standards symbols in my commits (mostly emojis 🙂), so I miss this type of menu in the app. As temporary solution I have to switch to terminal to provide commit message. Not very convenient 😞.

@davvid
Copy link
Member

davvid commented Sep 16, 2017

Ah... let me know if this sounds right: you're saying that on Linux, we don't have the Emoji & Symbols menu, but on macOS we do.

That's because of Qt using the native stuff on teach platform, but we could probably implement our own for Linux (and Windows too) where that menu is not provided by the OS.

Am I understanding that correctly? +1 from me

@kopach
Copy link
Contributor Author

kopach commented Sep 16, 2017

Not really. What I'm trying to say, is that there is no Edit menu in menubar in git-cola at all. So, if for example user would like to copy text not by keyboard shortcut, but from menubar - there is no such an option. Additionally in such Edit menu on Mac in almost all the programs - there is option Emoji & Symbols which allows to type special characters.

Here is an example of such Edit menu for Firefox on Mac

mac edit menu

I believe this is not a custom functionality but rather should be in standard QT library. Also have to mention that to type special characters on Linux (probably also on Windows) - there is system wide way to do so. On Mac - looks each program individually should provide an option to open system symbols window https://support.apple.com/en-us/HT201586

davvid added a commit to davvid/git-cola that referenced this issue Sep 20, 2017
Factor out the repeated actions into a reusable list.

Related-to: git-cola#725
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue Sep 20, 2017
Related-to: git-cola#725
Signed-off-by: David Aguilar <davvid@gmail.com>
davvid added a commit to davvid/git-cola that referenced this issue Sep 20, 2017
Add an "Edit" menu to the main menubar.

* edit-menu:
  qtutils: add add_menu() helper
  main: add an Edit menu
  commitmsg: refactor extra actions

Closes git-cola#725
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid davvid closed this as completed in 0aafd27 Sep 20, 2017
@kopach
Copy link
Contributor Author

kopach commented Sep 29, 2017

Hi @davvid. Thanks for implementing this functionality. It's really helpful. Anyway, looks like Emoji & Symbols Mac option for some reason is not working as expected. Let me show you:
git-cola-symbols
So, after I select special character - nothing is happening. Only if I move Emoji & Symbols window (actually make it independent of input field) it starts to work.

And here is how it suppose to work:
text-edit

@davvid
Copy link
Member

davvid commented Oct 1, 2017

Ah, interesting. Currently we basically hijack the menu from either of subject or extended description widgets, and make it available in the main menubar. I'll have to test this on macOS.

I'm curious -- does it work at all if you use the right-click context menu in the text fields and use the menu through there?

@kopach
Copy link
Contributor Author

kopach commented Oct 2, 2017

hi @davvid. Just tested it. Actually, there is no this option in right-click context menu.
edit-input

@davvid
Copy link
Member

davvid commented Oct 3, 2017

I tried this out on linux with the emoji-keyboard and the text fields work with unicode just fine, so I'm dusting off the macos laptop to try this out later. I have to wait for xcode to update so I can have my git toolchain back after the last macOS update ;-)

That menu item is being automatically provided by Qt (or the OS), so it may be that we have to implement some methods to make it start working canInsertFromMimeData() and insertMimeData() might both be needed.

@kopach
Copy link
Contributor Author

kopach commented Oct 3, 2017

Thanks @davvid. Looking forward for this fix 😊

@kopach
Copy link
Contributor Author

kopach commented Oct 3, 2017

hi @davvid. looks like the issue happens because of loosing focus by input field. Here is an example of html input in chrome browser:
input
As you may see - input never looses it's focus.

And here is and example from git-cola input - it looses focus when emoji window open (there is no cursor pointer in input field):
git-cola

davvid added a commit to davvid/git-cola that referenced this issue Oct 3, 2017
Ensure that the "Edit" menu is populated during startup so that
it is always displayed.  Not doing so causes the menu to not be
displayed on macOS unless the user switches away from the app,
which triggers an update when focus returns.

Related-to: git-cola#725
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid
Copy link
Member

davvid commented Oct 3, 2017

I noticed that the edit menu does not always display itself on macOS, so I tweaked it so that it's built during startup. Not directly related, but something I ran into while testing.

I was finally able to get reliable behavior out of the emoji window by clicking on the expand toggle button in the upper-right corner of the emoji window.

When in the expanded view, double-clicking the icons inserts the symbol into the text field. The focus thing is an interesting detail; maybe there's something we can do about that. I'll reopen this issue in case anyone has any other tricks we can do to make it more reliable.. at least it does seem to work in the expanded view..

@davvid davvid reopened this Oct 3, 2017
@kopach
Copy link
Contributor Author

kopach commented Oct 3, 2017

Actually, by clicking on the expand toggle button - input window gets it's focus again. the same situation happens when drag emoji window (#725 (comment))

@davvid
Copy link
Member

davvid commented Oct 4, 2017

This one is a real rabbit hole.. It only works when the window is moved/detached from the little "up" arrow indicator that's initially displayed, as you already know. We were doing something kinda funky where we were rebuilding the menu dynamically, but I've just changed that now to use a static Edit menu, which should at least rule that out as a possibility.

There's a chance that this may actually be a Qt bug, so it'd be good to report it upstream. The behavior is really consistent, and there's nothing that I can seem to do to make it work correctly.

Here is a minimal test case that shows the issue.

This is really starting to look like a QTBUG ~ the "Emoji & Symbols" menu is a built-in thing that is handled internally by Qt. In the code below all we do is create an Edit menu -- macOS/Qt does the rest automatically. The behavior is identical ~ it ignores the input, but works if I move or expand the emoji window. Bummer..

#!/usr/bin/env python

from PyQt5 import QtWidgets

app = QtWidgets.QApplication([])

window = QtWidgets.QMainWindow()
menubar = QtWidgets.QMenuBar(window)
menu = menubar.addMenu('Edit')
menu.addAction('Example')

widget = QtWidgets.QTextEdit()

window.setMenuBar(menubar)
window.setCentralWidget(widget)
window.show()

app.exec_()

@kopach
Copy link
Contributor Author

kopach commented Jan 8, 2018

Hi @davvid. Not sure, what has been changed. But in git-cola version 3.0 Emoji & Symbols menu works as expected. Maybe it also was a matter of OS version. Recently I've also updated my system to High Sierra v 10.13.2

@kopach kopach closed this as completed Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants