Add PgUp/Dn/Home/End to menu, bugfixes
This commit is contained in:
+32
-10
@@ -105,15 +105,37 @@ class Menu
|
||||
return array_keys($this->items)[$this->index];
|
||||
}
|
||||
} else {
|
||||
if ($ch == "k{UP}") {
|
||||
$this->index--;
|
||||
if ($this->index < 0) $this->index = count($this->items) - 1;
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
} elseif ($ch == "k{DOWN}") {
|
||||
$this->index++;
|
||||
if ($this->index >= count($this->items)) $this->index = 0;
|
||||
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
switch ($ch) {
|
||||
case "k{UP}":
|
||||
$this->index--;
|
||||
if ($this->index < 0) $this->index = count($this->items) - 1;
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
break;
|
||||
case "k{DOWN}":
|
||||
$this->index++;
|
||||
if ($this->index >= count($this->items)) $this->index = 0;
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
break;
|
||||
case "k{PGUP}":
|
||||
$this->index -= $height - 2;
|
||||
if ($this->index < 0) $this->index = count($this->items) - 1;
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
break;
|
||||
case "k{PGDN}":
|
||||
$this->index += $height - 2;
|
||||
if ($this->index >= count($this->items)) $this->index = 0;
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
break;
|
||||
case "k{HOME}":
|
||||
$this->index = 0;
|
||||
if ($this->index >= count($this->items)) $this->index = 0;
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
break;
|
||||
case "k{END}":
|
||||
$this->index = count($this->items) - 1;
|
||||
if ($this->index >= count($this->items)) $this->index = 0;
|
||||
$this->redraw($left, $top, $width, $height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,7 +168,7 @@ class Menu
|
||||
$scrollTop = $this->scroll;
|
||||
$scrollBottom = $scrollTop + $visibleItems - 1;
|
||||
$thumbTop = round(($visibleItems - 1) / count($this->items) * $scrollTop);
|
||||
$thumbBottom = round(($visibleItems - 1) / count($this->items) * $scrollBottom);
|
||||
$thumbBottom = round(($visibleItems) / count($this->items) * $scrollBottom);
|
||||
|
||||
$tleft = round(($width / 2) - ((mb_strlen($this->title) + 2) / 2));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user