X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Scroll Wheel Numbers in 5.3 (https://forum.x-cart.com/showthread.php?t=74962)

kirkbauer 02-05-2017 08:24 PM

Scroll Wheel Numbers in 5.3
 
In 5.2 many integer fields (e.g. "Quantity in Stock" on the view product screen) would allow you to increment/decrement the number using the mouse scroll wheel. When you click on the field it would show a little mouse icon next to the field to indicate this.

As far as I can tell this is gone from 5.3. Any idea how to get it back?

totaltec 02-06-2017 07:03 AM

Re: Scroll Wheel Numbers in 5.3
 
I can confirm that this is missing in one of my client 5.3 versions. I can;t find any settings in the admin dealing with this. It may have been intentionally removed, or it may be a bug...

qualiteam 02-06-2017 07:58 AM

Re: Scroll Wheel Numbers in 5.3
 
It was disabled intentionally, however can be re-enabled from a custom module.

Solution #1:
Decorate \XLite\View\FormField\Input\Text\Base\Numeric class from a custom module and set static::PARAM_MOUSE_WHEEL_CTRL to true.

Solution #2:
In templates that use this widget pass an extra parameter "mouseWheelCtrl" and set it to "true".
In widget classes that add this widget to a form, pass the extra PARAM_MOUSE_WHEEL_CTRL parameter.

kirkbauer 02-06-2017 09:15 AM

Re: Scroll Wheel Numbers in 5.3
 
Thanks for the quick response! I'm still pretty new to X-Cart development. I tried to override globally and it didn't work, did I do something wrong here?

Code:

namespace XLite\Module\KB\TDT\View\FormField;

class Numeric extends \XLite\View\FormField\Input\Text\Base\Numeric
{
    public function __construct(array $params = array())
    {
        static::PARAM_MOUSE_WHEEL_CTRL = true;
        parent::__construct($params);
    }
}


qualiteam 02-12-2017 11:48 PM

Re: Scroll Wheel Numbers in 5.3
 
No, I meant a bit different thing.

PARAM_MOUSE_WHEEL_CTRL is a widget parameter that is set in defineWidgetParams() method.
So, you should either decorate this method and set the parameter to true there, or tweak the getDefaultMouseWheelCtrlValue() method that returns the default value for the parameter.

Also, when you change the behavior of an existing class ("decorate" it), you should not just create a new class extending the existing one, but also mark it with the "implements" directive like this (also see how the namespace matches the namespace of the existing class - it is not a requirement, but a good practice):
PHP Code:

namespace XLite\Module\KB\TDT\View\FormField\Input\Text\Base;

class 
Numeric extends \XLite\View\FormField\Input\Text\Base\Numeric implements \XLite\Base\IDecorator
{
    protected function 
getDefaultMouseWheelCtrlValue()
    {
        return 
true;
    }



PhilJ 02-12-2017 11:53 PM

Re: Scroll Wheel Numbers in 5.3
 
yeah, that makes sense *cough*

kirkbauer 02-13-2017 05:26 AM

Re: Scroll Wheel Numbers in 5.3
 
That solution worked perfectly; thank you!

ITVV 02-13-2017 05:42 AM

Re: Scroll Wheel Numbers in 5.3
 
Quote:

Originally Posted by PhilJ
yeah, that makes sense *cough*

LOL :-) :-) :-) :-)


All times are GMT -8. The time now is 10:51 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.