MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / uitree_scroll

Function uitree_scroll

unity_cli/cli/commands/uitree.py:509–572  ·  view source on GitHub ↗

Scroll a ScrollView element. Two modes: Offset mode: --x and/or --y to set absolute scroll position. ScrollTo mode: --to to scroll a child element into view. Examples: u uitree scroll ref_5 --y 0 # Scroll to top u uitree scroll ref_5 -

(
    ctx: typer.Context,
    ref: Annotated[
        str | None,
        typer.Argument(help="Element reference ID (e.g., ref_5)"),
    ] = None,
    panel: Annotated[
        str | None,
        typer.Option("--panel", "-p", help="Panel name"),
    ] = None,
    name: Annotated[
        str | None,
        typer.Option("--name", "-n", help="Element name"),
    ] = None,
    x: Annotated[
        float | None,
        typer.Option("--x", help="Scroll offset X (absolute)"),
    ] = None,
    y: Annotated[
        float | None,
        typer.Option("--y", help="Scroll offset Y (absolute)"),
    ] = None,
    to: Annotated[
        str | None,
        typer.Option("--to", help="Ref ID of child element to scroll into view"),
    ] = None,
)

Source from the content-addressed store, hash-verified

507
508@uitree_app.command("scroll")
509def uitree_scroll(
510 ctx: typer.Context,
511 ref: Annotated[
512 str | None,
513 typer.Argument(help="Element reference ID (e.g., ref_5)"),
514 ] = None,
515 panel: Annotated[
516 str | None,
517 typer.Option("--panel", "-p", help="Panel name"),
518 ] = None,
519 name: Annotated[
520 str | None,
521 typer.Option("--name", "-n", help="Element name"),
522 ] = None,
523 x: Annotated[
524 float | None,
525 typer.Option("--x", help="Scroll offset X (absolute)"),
526 ] = None,
527 y: Annotated[
528 float | None,
529 typer.Option("--y", help="Scroll offset Y (absolute)"),
530 ] = None,
531 to: Annotated[
532 str | None,
533 typer.Option("--to", help="Ref ID of child element to scroll into view"),
534 ] = None,
535) -> None:
536 """Scroll a ScrollView element.
537
538 Two modes:
539 Offset mode: --x and/or --y to set absolute scroll position.
540 ScrollTo mode: --to <ref_id> to scroll a child element into view.
541
542 Examples:
543 u uitree scroll ref_5 --y 0 # Scroll to top
544 u uitree scroll ref_5 --y 500 # Scroll to y=500
545 u uitree scroll ref_5 --to ref_12 # Scroll child into view
546 """
547 context: CLIContext = ctx.obj
548
549 if not ref and not (panel and name):
550 _exit_usage("ref argument or --panel + --name required", "u uitree scroll")
551
552 if to is None and x is None and y is None:
553 _exit_usage("--x/--y or --to parameter required", "u uitree scroll")
554
555 try:
556 result = context.client.uitree.scroll(
557 ref=ref,
558 panel=panel,
559 name=name,
560 x=x,
561 y=y,
562 to_child=to,
563 )
564
565 elem_ref = escape(result.get("ref", ""))
566 offset = result.get("scrollOffset", {})

Callers

nothing calls this directly

Calls 5

_exit_usageFunction · 0.90
print_lineFunction · 0.90
_handle_errorFunction · 0.90
scrollMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected