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

Set default value for Select #169

Open
Cavaldier opened this issue Jun 12, 2019 · 7 comments
Open

Set default value for Select #169

Cavaldier opened this issue Jun 12, 2019 · 7 comments

Comments

@Cavaldier
Copy link

I want to set and display default value for select but i dont see any function for Select to set that. It issue or can be that in future? Someone can help?

@WinterSilence
Copy link

@Cavaldier u can extend any class. also u can set/get any other properties/classes from Lazarus elements/classes:

<?php

namespace Gui\Components;

/**
 * It is a visual component for spin input.
 *
 * @author WinterSilence
 * @since 0.1
 */
class SpinEdit extends VisualObject
{
    /**
     * @var string $lazarusClass The name of Lazarus class
     */
    protected $lazarusClass = 'TSpinEdit';
    
    /**
     * 
     * 
     * @return int
     */
    public function getValue()
    {
        return $this->get('Value');
    }
    
    /**
     * Sets the value.
     *
     * @param int $value
     * @return $this
     */
    public function setValue($value)
    {
        $this->set('Value', (int) $value);
        return $this;
    }
    /**
     * Get the maximal valueallowed for the spin edit.
     *
     * @return int
     */
    public function getMax()
    {
        return $this->get('MaxValue');
    }
    
    /**
     * 
     *
     * @param int $value
     * @return $this
     */
    public function setMax($value)
    {
        $this->set('MaxValue', (int) $value);
        return $this;
    }
    
    /**
     * Get the minimal valueallowed for the spin edit.
     *
     * @return int
     */
    public function getMin()
    {
        return $this->get('MinValue');
    }
    
    /**
     * Set the MinValue property equal to MaxValue to allow any number to be selected.
     *
     * @param int $value
     * @return $this
     */
    public function setMin($value)
    {
        $this->set('MinValue', (int) $value);
        return $this;
    }
    
    /**
     * The value by which the value of the control should be increased/decresed when 
     * the user clicks one of the arrows or one of the keyboard up/down arrows.
     *
     * @param int $value
     * @return $this
     */
    public function setIncrement($value)
    {
        $this->set('Increment', (int) $value);
        return $this;
    }
}

but need recompile /php-gui/lazarus/ before

@Cavaldier
Copy link
Author

@WinterSilence ok, but i dont want to recompile all project. I using only netbeans and i cant recompile lazarus ;/ so that to set "default value" for select wont be created?

@WinterSilence
Copy link

@Cavaldier extends class https://github.com/gabrielrcouto/php-gui/blob/master/src/Components/Select.php

<?php
namespace Gui\Components;

class Select2 extends Select
{
    public function __construct(
        array $defaultAttributes = [],
        ContainerObjectInterface $parent = null,
        $application = null
    ) {
        parent::__construct($defaultAttributes, $parent, $application);
        // Select item with index 1 by default
        $this->set('itemIndex', 1);
    }
}

@Cavaldier
Copy link
Author

Cavaldier commented Jun 26, 2019

But that only work on 0.1.1 version gui, how do it on 0.1? I got outdated library, but i dont want to upgrade to newest, because its too much work to refactor all in my project. My Select class extends Object, not VisualObject @WinterSilence

@WinterSilence
Copy link

@Cavaldier then its u problem, need write something like this.

@Cavaldier
Copy link
Author

@WinterSilence can you tell me how i can show multiple application with diffrent items? Because when i adds items all goes to first window, not second(declared second new Application)

@WinterSilence
Copy link

@Cavaldier facepalm...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants