I am trying to bind my Enter button on my keyboard. I am writing in Perl Tk.
I want one of the next to things to happen.
- When I hit "Enter" on my keyboard, I want a button within my program to operate.
- When I hit "Enter" on my keyboard, I want a subroutine to run. Either one would satisfy my program seeing that my button opens the subroutine.
Here is my relevant code:
# Button
my $enterbut = $find_sub->Button(
-command => \&find_substations,
-text => 'Find Displays',
-background => 'gray'
)->pack(
-side => 'left',
-fill => 'none',
-ipadx => 8,
-ipady => 1
);
# Accept "Enter" key as input
$enterbut->bind('<Return>', \&find_substations);
# Output Substation ID to Pane
sub find_substations {
print;
}
I have tried a few different ways of using the bind command and none of them works.
I am getting no errors but when I press the button my sub does not operate. I begin to believe Return may not be the correct button on my keyboard. Maybe due to driver language or something. Maybe coding error.