Context Menu modes

Context Menu Mode Switch

Currently, EiffelStudio has two pebble transport mechanism for performing command shortcuts within the IDE, these modes are Pick and Drop and new for EiffelStudio 6.0, Contextual Menus. They are closely related in the sense that they both provide a mechanism for transporting a pebble source to a destination target.

Previous EiffelStudio versions have only included the Pick and Drop pebble transport mechanism but this is not a standard way of performing tasks and can be somewhat alien to new users. The Contextual Menus have been added as a way for EiffelStudio to entice new users by providing a more recognisable approach to accessing the facilities that the IDE provides.

Setting the default transport mode

In the EiffelStudio preferences window, there is a preference for deciding what pebble transport mechanism should be the default. This is located in General /Pnd mode where True is for pick and drop mode and False is to use Contextual Menus as the default mode, this preference is subject to change.

Activating a pebble transportation

EiffelStudio has many potential pebble sources, the most prevalent ones being Class pebbles and Feature pebble. A simple right click on a pebble will activate the transport mechanism and a command to be performed on that pebble can be achieved either by dropping the pebble on to a highlighted source (if in Pick and Drop mode) or selected via a Contextual Menu item.

Switching from one mode to the other

Even though one mechanism is default, the use of the shift key whilst activating the transport mechanism with a right mouse click can be used to switch from the default mechanism to the other.

Using the mechanism with EiffelVision 2

This mechanism is built in to Vision2 and use of the original pick and drop can be updated to use the Context Menu mechanism, this is demonstrated with the following code segments.

pebble_source_widget.set_pebble ("STRING pebble")
 
pebble_source_widget.set_configurable_target_menu_mode;
pebble_source_widget.set_configurable_target_menu_handler (agent target_menu_handler)
 
 
pebble_target_widget.drop_actions.extend (agent print)
pebble_target_widget.set_target_data_function (agent target_data_function)
 
 
target_menu_handler (
     a_menu: EV_MENU;
     a_target_list: ARRAYED_LIST [EV_PND_TARGET_DATA];
     a_source: EV_PICK_AND_DROPABLE;
     a_pebble: ANY
  )
 
    do
        -- Within this feature you can manipulate `a_menu' to add custom menu items
        -- `a_menu' must be populated by this routine, if `a_menu' is untouched,
        -- a regular pick and drop transport will initiate.
        -- a_target_list is an array of all the potential targets for `a_pebble', the 
        -- meta data includes target, menu text and pixmap (if applicable), this can be
        -- customized for each target with {EV_PICK_AND_DROPABLE}.set_target_data_function.
        -- `a_source' is the pebble source widget.
        -- `a_pebble' is the pebble in question.
 
        a_menu.extend (create {EV_MENU_ITEM}.make_with_text (a_target_list.first.name))
    end
 
pebble_target_widget.set_target_data_function (agent target_data_function)
 
target_data_function (a_pebble: ANY): EV_PND_TARGET_DATA
    local
        l_string: STRING
    do
        l_string ?= a_pebble
        if l_string /= Void
          create Result
          Result.set_name ("Print the string " + a_pebble)
        end
    end