haxeui / haxeui-core

The core library of the HaxeUI framework
http://haxeui.org
MIT License
346 stars 72 forks source link

Slider crashes with 'Null object reference' #294

Closed kevansevans closed 5 years ago

kevansevans commented 5 years ago

OpenFL backend, using master branch of haxeui-core and haxeui-openfl.

Expected Behavior

A new slider should be made without any hiccups.

Current Behavior

Creating a new Slider causes a null object crash

Possible Solution

Finish this function here so it doesn't return null: https://github.com/haxeui/haxeui-core/blob/379289399ef424a4389418b58ab198adcef68467/haxe/ui/components/Slider.hx#L267

Steps to Reproduce (for bugs)

Create new openFL project. Use master branches of both haxeui-core and haxeui-openfl Write anything that lets you instantiate a new slider. haxe.ui.components.Slider; Compile to Windows/CPP. Use -debug flag to get error box. Program crashes with no warning otherwise.

Media

https://www.dropbox.com/s/8tu1d1dicimx969/Screenshot%202019-08-08%2014.30.55.png?dl=0

Test app / minimal test case

package;

import openfl.display.Sprite;
import openfl.Lib;

import haxe.ui.Toolkit;
import haxe.ui.components.Slider;

class Main extends Sprite 
{
    public function new() 
    {
        super();

        Toolkit.init();
        var slidy = new Slider(); //crash
    }
 }

https://www.dropbox.com/s/66rjqfobvlx6pec/HaxeUIissue.7z?dl=0

Context

I need a horizontal slider. Can't use a horizontal slider if it crashes.

Your Environment

Windows 10 desktop. Using HaxeDevelop IDE. Using windows/cpp as target. Both latest OpenFL and Lime versions. Haxe 4 RC3

ianharrigan commented 5 years ago

Thanks, this is a perfect repro.

ianharrigan commented 5 years ago

HorzionalSlider should be used (same goes for any "directional" controls). Note when using xml, this is required, you can use:

<slider direction="vertical|horizontal" /> and the macro will build the correct class name for you. I do wonder though if it might make sense to have a default impl, like "Slider" being a horizontal slider. Ill have to think about it.

In the mean time, can this be closed?

Cheers, Ian

kevansevans commented 5 years ago

Yes, this can be closed. Apologies for the late reply.