Dialog List Not Working Correctly (always cancelled unless double clicked)

13 views
Skip to first unread message

Dennis Bareis

unread,
May 24, 2021, 6:27:05 PM5/24/21
to CopyQ
Hi,

This code (from your doco):

    var items = ['a', 'b', 'c']
    MyLog('Showing Dialog')
    var selected_index = dialog('.list:Select', items)
    if (selected_index)
        MyLog('Selected item: ' + items[selected_index])
    else
        MyLog('{{CANCELLED BY USER}}')

Fails every time UNLESS one of the items is double clicked before terminating the dialog, neither the default (first item) or the single clicked item is selected (other than visually in the dialog).

This is on Windows.  There are some other issues as listed here, can anything be done:
  1. The dialog doesn't show on the Windows taskbar and that can mean that the dialog can get "lost" with no simple way to get to it other than to keep minimising windows until it is located.
  2. There is no way to control the width of the above dialog, I do not want a horizontal scroller unless it's required based on the screen size.
  3. The previously in-focus window is no longer in focus (after dialog exits).
  4. It would be great if the window position (and size if resize is possible) could be remembered somehow.

Lukáš Holeček

unread,
May 26, 2021, 8:24:33 AM5/26/21
to Dennis Bareis, CopyQ
Branch "if (selected_index) ..." will not be executed if the selected index is 0. It should be: if (selected_index !== undefined)

ad 1. This is probably because parent window of the dialog is CopyQ. I think the behavior might depend on the window manager (or OS).
ad 2. You can use special '.width' (and '.height') parameter: dialog(..., '.width', 500, ...)
ad 3. I don't think I can control this - it is probably again a behavior of the window manager or Qt framework.
ad 4. Good idea: https://github.com/hluk/CopyQ/pull/1672 - makes sense if the dialog can be identified uniquely - in this case maybe using the special argument '.title'

Lukas


--
You received this message because you are subscribed to the Google Groups "CopyQ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to copyq+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/copyq/e93c3505-47fc-4c37-b6ee-85b258fe940en%40googlegroups.com.

Dennis Bareis

unread,
May 26, 2021, 5:01:10 PM5/26/21
to CopyQ
Hi,

RE:  "if (selected_index) ..." , this is exactly from your example, if it is "correct" then the example needs more explanation.

RE: A1/3: I'm not sure what you mean by "window manager" so I'm just clarifying that this is not a Windows OS issue,  it would be an issue (or limitation) in the framework or how it is invoked.

RE: A2, thanks I will do that but I still think it should autosize past where it does now (basically to fit the contents like it does when there is less of it)

RE: A4: Thanks, maybe user can at least optionally supply a Window ID to force uniqueness if required.

Dennis

Lukáš Holeček

unread,
May 27, 2021, 1:11:37 AM5/27/21
to Dennis Bareis, CopyQ
On Wed, May 26, 2021 at 11:01 PM Dennis Bareis <dba...@gmail.com> wrote:
Hi,

RE:  "if (selected_index) ..." , this is exactly from your example, if it is "correct" then the example needs more explanation.

Ah, OK, I fixed the example in documentation.


RE: A1/3: I'm not sure what you mean by "window manager" so I'm just clarifying that this is not a Windows OS issue,  it would be an issue (or limitation) in the framework or how it is invoked.

RE: A2, thanks I will do that but I still think it should autosize past where it does now (basically to fit the contents like it does when there is less of it)

The size of the dialog is adjusted to fit all the widgets, but the behavior depends on Qt framework. I hope they can improve this in the future.

Reply all
Reply to author
Forward
0 new messages