Source

Kephra / lib / Kephra / App / Focus.pm

use v5.10;
use strict;
use warnings;
use Wx;
use Kephra::API;

package Kephra::App::Focus;

my @focus_stack = ();

sub get { $focus_stack[0] }

sub set {
	my ($widget) = @_;
	print scalar @focus_stack, " $widget --\n";
	return Kephra::Log::warning( "got no proper widget ($widget) from ". (caller)[0] )
		unless Kephra::App::Util::is_widget($widget);
	return Kephra::Log::warning( "$widget is already in focus") if get() and $widget eq get();
	unshift @focus_stack, $widget;
	stay();
}
sub set_back {
	my ($times) = shift // 1;
	for (1 .. $times) { shift @focus_stack if @focus_stack > 1 }
	stay();
}

sub stay { Wx::Window::SetFocus( get() ) }



1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.