PHP code example of dmvdbrugge / dynamic-components
1. Go to this page and download the library: Download dmvdbrugge/dynamic-components library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dmvdbrugge / dynamic-components example snippets
use DynamicComponents\Controls\Button;
$button = new Button('Click me!', function (Button $button) {
$button->setText('You clicked :D');
});
use UI\Controls\Button;
$button = new class('Click me!') extends Button {
protected function onClicked(): void
{
$this->setText('You clicked :D');
}
};
use DynamicComponents\Controls\Button;
$onClick = function (Button $button) {
$button->setText('You clicked :D');
};
$button1 = new Button('Click me!', $onClick);
$button2 = new Button('Click me!', $onClick);
$button3 = new Button('Click me!', $onClick);
// Constructor
// Relevant overridden methods, if any
// Additional methods
// Constructor
public function __construct(string $text, ?callable $onClick = null)
// Additional methods
public function setOnClick(callable $onClick): void
// Constructor
public function __construct(string $text, ?callable $onToggle = null, bool $checked = false)
// Additional methods
public function setOnToggle(callable $onToggle): void
// Constructor
public function __construct(?callable $onChange = null, ?Color $color = null)
// Additional methods
public function setOnChange(callable $onChange): void
// Constructor
public function __construct(?callable $onSelected = null)
// Additional methods
public function setOnSelected(callable $onSelected): void
// Constructor
public function __construct(?callable $onChange = null, string $text = '')
// Additional methods
public function setOnChange(callable $onChange): void
// Constructor
public function __construct(int $type = Entry::Normal, ?callable $onChange = null, string $text = '', bool $readOnly = false)
// Additional methods
public function getType(): int
public function setOnChange(callable $onChange): void
// Constructor
public function __construct(int $type = MultilineEntry::Wrap, ?callable $onChange = null, string $text = '', bool $readOnly = false)
// Additional methods
public function getType(): int
public function setOnChange(callable $onChange): void
// Constructor
public function __construct(?callable $onSelected = null)
// Additional methods
public function setOnSelected(callable $onSelected): void
// Constructor
public function __construct(int $min, int $max, ?callable $onChange = null, ?int $value = null)
// Additional methods
public function getMax(): int
public function getMin(): int
public function setOnChange(callable $onChange): void
// Constructor
public function __construct(int $min, int $max, ?callable $onChange = null, ?int $value = null)
// Additional methods
public function getMax(): int
public function getMin(): int
public function setOnChange(callable $onChange): void
// Constructor
public function __construct(string[] $options, ?callable $onSelected = null, int|string $selected = 0)
// Additional methods
public function appendAll(string[] $options): void
public function getOptions(): string[]
public function getSelectedText(): string
public function setSelectedText(string $text): void
// Constructor
public function __construct(string[] $options, ?callable $onSelected = null, int|string $selected = -1)
// Additional methods
public function appendAll(string[] $options): void
public function getOptions(): string[]
public function getSelectedText(): string
public function setSelectedText(string $text): void
// Constructor
public function __construct(?callable $onDraw = null, ?callable $onKey = null, ?callable $onMouse = null)
// Additional methods
public function setOnDraw(callable $onDraw): void
public function setOnKey(callable $onKey): void
public function setOnMouse(callable $onMouse): void
// Constructor
public function __construct(int $seconds = 0, ?int $microseconds = null, ?callable $onExecute = null)
// Additional methods
public function getInterval(): int[]
public function setOnExecute(callable $onExecute): void
// Constructor
public function __construct(string $name)
// Relevant override (default param changes)
public function append(string $name, string $type = \DynamicComponents\MenuItem::class): \UI\MenuItem
// Additional methods
public function add(string $name): \DynamicComponents\MenuItem
public function addAs(string $type, string $name): \UI\MenuItem
public function getName(): string
public function getMenuItemName(\UI\MenuItem $menuItem): string
public function hasMenuItem(\UI\MenuItem $menuItem): bool
// No constructor, MenuItems are created by a Menu via append()
// Additional methods
public function getName(): ?string
public function getParent(): \DynamicComponents\Menu
public function isEnabled(): bool
public function setOnClick(callable $onClick): void
// Constructor
public function __construct(string $title, \UI\Size $size, bool $menu = false, ?callable $onClosing = null)
// Additional methods
public function hasMenu(): bool
public function setOnClosing(callable $onClosing): void
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.