Herbert Breunung avatar Herbert Breunung committed e8a3a83

menu calls work again

Comments (0)

Files changed (2)

lib/Kephra/API/Command.pm

 use strict;
 use warnings;
+use v5.10;
 use Kephra::API;
 
 package Kephra::API::Command;                             # callable by the user
 	my $api = 'Kephra::API';
 	my $caller = calling_module();
 	return Kephra::Log::error("only callable by $api", 1) if $caller ne $api;
-	return Kephra::Log::error("has to be called before init", 1)
-		if $done_init and not keys %switchvar;
 	#return Kephra::Log::error("call me just once", 1) if keys %switchvar;
 	return Kephra::Log::error("need a hashref", 1) unless ref $var_def eq 'HASH';
 	for my $var (keys %$var_def){
 		delete $var_def->{$var} unless package_exists ( $var_def->{$var}{'class'} );
 	}
 	%switchvar = %$var_def;
+	compile( keys %list );
+	$done_init = 1;
 }
 
 sub register {
 	}
 }
 
-sub init {
-	compile( keys %list );
-	$done_init = 1;
-}
-
 sub compile {
 	for my $cmd_ID (@_) {
 		my $cmd = $list{ $cmd_ID };

lib/Kephra/App/Menu.pm

 use strict;
 use warnings;
+use v5.10;
 use Wx;
 
 use Kephra::API;
 
 			my $cmd_data = Kephra::API::Command::all_properties( $item_def );
 			next unless ref $cmd_data;
+say $item_def, " ", $cmd_data->{'sub'},"-",$cmd_data->{'coderef'};
 			push @menu_data, {
 				'type' => 'item',
 				'label'=> ucfirst $cmd_data->{'label'},
 				my $item = Wx::MenuItem->new(
 					$menu, $item_ID, $item_data->{'label'}, ' ', &Wx::wxITEM_NORMAL
 				);
-				if (defined $item_data->{icon}) {
-					#my $bmp = ;
-					#$menu_item->SetBitmap( $bmp ) 
-					#	if ref $bmp eq 'Wx::Bitmap' and not Wx::wxMAC();
+				if (defined $item_data->{'bitmap'}) {
+					$item->SetBitmap( $item_data->{'bitmap'} ) 
+						if ref $item_data->{'bitmap'} eq 'Wx::Bitmap' and not Wx::wxMAC();
 				}
 				Wx::Event::EVT_MENU( $win, $item_ID, $item_data->{'coderef'} );
 				$menu->Append( $item );
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.