451 views
in GUI Development by

Sorry, due I was a beginner of Embeddid Wizard, but my project on going now. I need you to help me evaluate the feasibility of my project plan. I just want to know is possible or not, difficult or easy.

This plan is difficult explain by mail, so I made a EXCEL file as attached.

(http://ask.embedded-wizard.de/?qa=blob&qa_blobid=7287504110131698159)

(I used DEMO PROJECT of 'x:\Program Files (x86)\EmbeddedWizard\Examples_Mosaic20\Menus')

* Is this plan possible to do in Embeddid Wizard?

* If is possible, is difficulties of not?

* If is possible, please help simple explanation how I should do next.

So many thanks.

1 Answer

0 votes
by
 
Best answer

Yes. Such behavior can be implemented. With the underlying programming language Chora, you are very flexible to implement any design specific GUI behaviors.
In respect of your particular application case of a 'shortcut driven menu system' I think the following approach is very reasonable. It consists of two parts:

Part 1: Adding a 'shortcut' functionality to menu items.

Part 2: Conversion of a single key event to several key events leading to the desired sub-menu level.

Let's start with the part #1:
---> In your 'menu item' class:

Step 1: Add a new property.

Step 2: Delete the 'OnSet...' and 'OnGet...' methods belonging to the just added property. These are not needed here.

Step 3: Rename the property to 'Shortcut'.

Step 4: Change the 'Type' attribute of the property to 'char' and its 'Default' attribute to 'A'.

The intention of the just added property is the storage of a character code which should activate the item.

---> In your basic 'menu' class:

Step 5: Add a new 'Key Press Handler'.

Step 6: Change the property 'Filter' of the just added handler to the value 'Core::KeyCode.AlphaKeys'.

Step 7: Add a new 'Slot' method.

Step 8: Assign the just added 'Slot' method to the 'Key Press Handler' property 'OnPress'.

Step 9: Implement the 'Slot' method. The following code demonstrates it:

// Ignore 'key release' events.
if ( !KeyHandler.Down )
 return;

// Get the code of the just pressed key and the first item in the menu
var char       charCode = KeyHandler.CharCode.upper;
var Core::View view     = Outline.FindNextView( null, Core::ViewState[]);

while ( view != null )
{
 var Component::MenuItem item = (Component::MenuItem)view;

 // Can the item react to the shortcut?
 if (( item != null ) && ( item.Shortcut.upper == charCode ))
 {
   // Select the item in contect of the menu
   Focus = item;

   // and then simulate as if the user has activated the item.
   postsignal item.OnActivate;

   // Done.
   return;
 }

 // Try the next item
 view = Outline.FindNextView( view, Core::ViewState[]);  
}

// No item found with shortcut corresponding to the pressed.
// Give the owner of the menu a chance to process the key event.
KeyHandler.Continue = true;

With these steps the 'Slot' method is called every time the user presses an alpha key (a, b ... z). Then the 'Slot' method evaluates all items contained in the affected menu and looks for an item which has a shortcut key code corresponding to the just pressed key. If found, the item is selected and activated.

---> In your specific 'menu' classes (e.g. 'picture menu'):

Step 10: Assign to every item the corresponding shortcut key code. E.g. 'D', 'E', ...

Now when the menu is opened you should be able to select and activate the menu items by pressing the corresponding key.

Let's continue with the part #2:
Here we address the instantiation of the correct menu accordingly to the pressed key.

---> In your basic 'application' class:

Step 11: Add a new 'Key Press Handler'.

Step 12: Change the property 'Filter' of the just added handler to the value 'Core::KeyCode.AlphaKeys'.

Step 13: Add a new 'Slot' method.

Step 14: Assign the just added 'Slot' method to the 'Key Press Handler' property 'OnPress'.

Step 15: Implement the 'Slot' method. The following code demonstrates it:

// Ignore 'key release' events.
if ( !KeyHandler.Down )
 return;

// Already a menu is opened
if ( GetModalGroup() != null )
 return;

// Get the code of the just pressed key
var char charCode = KeyHandler.CharCode.upper;

// The range of shortcuts from the e.g. 'picture menu'
if ((( charCode >= 'E' ) && ( charCode <= 'P' )) || ( charCode == 'A' ))
{
 var MenuList::Menu_PICTURE menu = new  MenuList::Menu_PICTURE;

 menu.OnExit = onExitMenu;
 menu.FadeIn( this );
 GetRoot().BeginModal( menu );

 // Send a key event to the menu is if the user has pressed a key
 if (( charCode >= 'E' ) && ( charCode <= 'P' ))
   menu.DispatchEvent(( new Core::KeyEvent ).Initialize2( charCode, true ));

 // Done
 return;
}

// The range of shortcuts from the e.g. 'audio menu'
if (( charCode >= 'Q' ) && ( charCode <= 'U' ))
{
 /* ... */
}

// Not processed.
// Give the owner of the menu a chance to process the key event.
KeyHandler.Continue = true;

The intention of this code is to create and show a menu corresponding to the pressed key and evtl. activate a menu item in this menu. Similarly you can create and show more complex menu hierarchy.

Although the example is very simple, it demonstrates the key ideas. In the practice there are some additional aspects you should consider:

Aspect 1: Implement the code to create/show a sub-menu in the corresponding superior menu.
For example, in the top-level menu add a 'Slot' method to react to the activation of e.g. 'Picture Settings' menu item. Then in this 'Slot' method create a new instance of the picture menu, add the menu to the root object to make it visible (GetRoot().Add(...)) and make it modal (GetRoot().BeginModal(...)).

Aspect 2: If you want to close all menus when the user presses the ESC key, implement a loop which closes all currently modal menus. Use the method GetModalGroup() to determine whether and which menu is opened.
 

Aspect 3: Simplify the 'Slot' method in the application:
It would be sufficient to create the top-level menu and to feed it with key events to open the sub-menus as if the user has pressed these keys.

Aspect 4: Implement a 'generic framework' for your menu system:
Currently we are playing with examples of simple menus. When you understood the basic concepts you should be able to specify and implement a generic 'Menu', 'MenuItem', 'Application' classes which provide a common (framework) functionality for the menu system.
Then you can simply derive from the generic 'Menu' class your specific menu components and fill these with items. Add implementation to react to the activation of an item and so far. The basic (framework) implementation handles all common aspects like the creation, navigation or even the dismissing of a menu or menu hierarchy.

Embedded Wizard Website | Privacy Policy | Imprint

...