From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 45A757BC75
 for <pve-devel@lists.proxmox.com>; Wed, 13 Jul 2022 11:50:21 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 39C09CB4
 for <pve-devel@lists.proxmox.com>; Wed, 13 Jul 2022 11:49:51 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Wed, 13 Jul 2022 11:49:50 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6F2C341F6B
 for <pve-devel@lists.proxmox.com>; Wed, 13 Jul 2022 11:49:50 +0200 (CEST)
Message-ID: <99097960-883b-a4dc-2d5e-910a438b2e2f@proxmox.com>
Date: Wed, 13 Jul 2022 11:49:49 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.11.0
Content-Language: en-US
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Daniel Tschlatscher <d.tschlatscher@proxmox.com>
References: <20220707134132.391584-1-d.tschlatscher@proxmox.com>
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <20220707134132.391584-1-d.tschlatscher@proxmox.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.099 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -0.001 Looks like a legit reply (A)
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: Re: [pve-devel] [PATCH widget-toolkit] fix: gui: up/down arrow keys
 increment/decrement twice in Number field
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 13 Jul 2022 09:50:21 -0000

man, extjs overrides are weird. i was convinced that even
the onRender gets 'overridden' and not simply called from a subclass?

anyway in that case the fix looks ok, but i think we can even go 
further. since the original code will evidently be called,
how about we remove the original 'onMouseWheel' handler too?

we'd probably have to do something like:

---8<---
if (me.mouseWheelEnabled) {
    me.mun(me.bodyEl, 'mousewheel', me.onMouseWheel, ...)
...
}
--->8---
(untested ofc)

i guess it works currently because the 'mousewheel' event
does not even trigger? (idk though)

also the 'spin{Up/Down}El' part at the end of the function is probably
unnecessary too since the 'callParent' call already takes care of that

On 7/7/22 15:41, Daniel Tschlatscher wrote:
> When the up or down arrow key on the keyboard was pressed while a
> number text field (or any one descending from Ext.form.field.Spinner)
> was selected, the up and down callbacks for that text fields KeyNav
> were called twice. Therefore, the value in the text field would always
> incorrectly increment/decrement by step * 2.
> 
> The problem was an overwrite for the onRender() method of the Spinner
> class, which caused the callbacks for pressing an arrow key to be
> registered for a second time. Simply not doing that in the overwritten
> onRender() method fixes the problem.
> 
> Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
> ---
>   src/Toolkit.js | 15 ---------------
>   1 file changed, 15 deletions(-)
> 
> diff --git a/src/Toolkit.js b/src/Toolkit.js
> index a1d291e..0ce5185 100644
> --- a/src/Toolkit.js
> +++ b/src/Toolkit.js
> @@ -469,21 +469,6 @@ Ext.define('Proxmox.form.field.Spinner', {
>   
>   	me.callParent();
>   
> -	// Init up/down arrow keys
> -	if (me.keyNavEnabled) {
> -	    me.spinnerKeyNav = new Ext.util.KeyNav({
> -		target: me.inputEl,
> -		scope: me,
> -		up: me.spinUp,
> -		down: me.spinDown,
> -	    });
> -
> -	    me.inputEl.on({
> -		keyup: me.onInputElKeyUp,
> -		scope: me,
> -	    });
> -	}
> -
>   	// Init mouse wheel
>   	if (me.mouseWheelEnabled) {
>   	    me.mon(me.bodyEl, 'wheel', me.onMouseWheel, me);