| 168 | |
| 169 | |
| 170 | void ScrollWidget::onHoverKey(const HoverKeyEvent& e) { |
| 171 | OpaqueWidget::onHoverKey(e); |
| 172 | if (e.isConsumed()) |
| 173 | return; |
| 174 | |
| 175 | // Check if scrollable |
| 176 | math::Rect offsetBound = getContainerOffsetBound(); |
| 177 | if (offsetBound.size.x <= 0.f && offsetBound.size.y <= 0.f) |
| 178 | return; |
| 179 | |
| 180 | if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { |
| 181 | if (e.isKeyCommand(GLFW_KEY_PAGE_UP)) { |
| 182 | offset.y -= box.size.y * 0.5; |
| 183 | e.consume(this); |
| 184 | } |
| 185 | if (e.isKeyCommand(GLFW_KEY_PAGE_UP, GLFW_MOD_SHIFT)) { |
| 186 | offset.x -= box.size.x * 0.5; |
| 187 | e.consume(this); |
| 188 | } |
| 189 | if (e.isKeyCommand(GLFW_KEY_PAGE_DOWN)) { |
| 190 | offset.y += box.size.y * 0.5; |
| 191 | e.consume(this); |
| 192 | } |
| 193 | if (e.isKeyCommand(GLFW_KEY_PAGE_DOWN, GLFW_MOD_SHIFT)) { |
| 194 | offset.x += box.size.x * 0.5; |
| 195 | e.consume(this); |
| 196 | } |
| 197 | if (e.isKeyCommand(GLFW_KEY_HOME)) { |
| 198 | math::Rect containerBox = container->getVisibleChildrenBoundingBox(); |
| 199 | offset.y = containerBox.getTop(); |
| 200 | e.consume(this); |
| 201 | } |
| 202 | if (e.isKeyCommand(GLFW_KEY_HOME, GLFW_MOD_SHIFT)) { |
| 203 | math::Rect containerBox = container->getVisibleChildrenBoundingBox(); |
| 204 | offset.x = containerBox.getLeft(); |
| 205 | e.consume(this); |
| 206 | } |
| 207 | if (e.isKeyCommand(GLFW_KEY_END)) { |
| 208 | math::Rect containerBox = container->getVisibleChildrenBoundingBox(); |
| 209 | offset.y = containerBox.getBottom(); |
| 210 | e.consume(this); |
| 211 | } |
| 212 | if (e.isKeyCommand(GLFW_KEY_END, GLFW_MOD_SHIFT)) { |
| 213 | math::Rect containerBox = container->getVisibleChildrenBoundingBox(); |
| 214 | offset.x = containerBox.getRight(); |
| 215 | e.consume(this); |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | |
| 221 | } // namespace ui |
nothing calls this directly
no test coverage detected