Skip to content

![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) #5

@Jakobish

Description

@Jakobish

medium

The New-ActionButton function has a hidden dependency on the $toolTip variable, which is defined in the script's scope. This tight coupling makes the function less portable and harder to reason about in isolation. To improve encapsulation and reusability, consider passing the ToolTip component as an explicit parameter. You will need to update the calls to this function to pass $toolTip.

function New-ActionButton {
    param(
        [string]$Text,
        [string]$TooltipText,
        [System.Windows.Forms.ToolTip]$ToolTip
    )

    $btn = New-Object System.Windows.Forms.Button
    $btn.Text = $Text
    $btn.Width = 300
    $btn.Height = 25
    if ($TooltipText -and $ToolTip) {
        $ToolTip.SetToolTip($btn, $TooltipText)
    }
    return $btn
}

Originally posted by @gemini-code-assist[bot] in #1 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions