Module: AMS::Menu

Defined in:
menu.rb

Class Method Summary (collapse)

Class Method Details

+ (Boolean) end

Deactivate active context menu.

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



28
29
30
# File 'menu.rb', line 28

def end
  AMC::C.end_menu()
end

+ (Hash{String => Fixnum}) get_commands(handle, cur_path = '')

Get menu commands.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

  • cur_path (String) (defaults to: '')

    Current menu path

Returns:

  • (Hash{String => Fixnum})

    { path => id, … }

Since:

  • 2.0.0



119
120
121
122
# File 'menu.rb', line 119

def get_commands(handle, cur_path = '')
  validate(handle)
  AMS::C.get_menu_commands(handle, cur_path.to_s)
end

+ (Fixnum) get_item_count(handle)

Get menu item count.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

Returns:

  • (Fixnum)

    count

See Also:

Since:

  • 2.0.0



37
38
39
40
# File 'menu.rb', line 37

def get_item_count(handle)
  validate(handle)
  AMS::C.get_menu_item_count(handle)
end

+ (Fixnum) get_item_id(handle, index)

Get menu item id by item position.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

  • index (Fixnum)

Returns:

  • (Fixnum)

    Menu item identifier if successful or -1 if not.

See Also:

Since:

  • 2.0.0



48
49
50
51
# File 'menu.rb', line 48

def get_item_id(handle, index)
  validate(handle)
  AMS::C.get_menu_item_id(handle, index.to_i)
end

+ (String?) get_menu_item_string_by_id(handle, id)

Get menu item string by item identifier.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

  • id (Fixnum)

Returns:

  • (String, nil)

    Menu item string if successful or nil if not.

See Also:

Since:

  • 2.0.0



83
84
85
86
87
88
# File 'menu.rb', line 83

def get_menu_item_string_by_id(handle, id)
  validate(handle)
  str = AMS::C.get_menu_item_string_by_id(handle, id.to_i)
  str = str.unpack('C*').pack('U*') if str
  str
end

+ (String?) get_menu_item_string_by_pos(handle, index)

Get menu item string by item position.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

  • index (Fixnum)

Returns:

  • (String, nil)

    Menu item string if successful or nil if not.

See Also:

Since:

  • 2.0.0



70
71
72
73
74
75
# File 'menu.rb', line 70

def get_menu_item_string_by_pos(handle, index)
  validate(handle)
  str = AMS::C.get_menu_item_string_by_pos(handle, index.to_i)
  str = str.unpack('C*').pack('U*') if str
  str
end

+ (Fixnum?) get_sub_menu(handle, index)

Get menu sub-menu handle by sub-menu position.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

  • index (Fixnum)

Returns:

  • (Fixnum, nil)

    A handle to sub-menu if successful or nil if not.

See Also:

Since:

  • 2.0.0



59
60
61
62
# File 'menu.rb', line 59

def get_sub_menu(handle, index)
  validate(handle)
  AMS::C.get_sub_menu(handle, index.to_i)
end

+ (Boolean) is_valid?(handle)

Determine whether handle is a reference to a valid menu.

Parameters:

  • handle (Fixnum)

    A menu handle to be tested.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0



20
21
22
# File 'menu.rb', line 20

def is_valid?(handle)
  AMS::C.is_menu?(handle)
end

+ (Boolean) set_menu_item_string_by_id(handle, id, string)

Set menu item string by item identifier.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

  • id (Fixnum)
  • string (String)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



109
110
111
112
# File 'menu.rb', line 109

def set_menu_item_string_by_id(handle, id, string)
  validate(handle)
  AMS::C.set_menu_item_string_by_id(handle, id.to_i, string.to_s.unpack('U*').pack('C*'))
end

+ (Boolean) set_menu_item_string_by_pos(handle, index, string)

Set menu item string by item position.

Parameters:

  • handle (Fixnum)

    A handle to the valid menu or sub-menu.

  • index (Fixnum)
  • string (String)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



97
98
99
100
# File 'menu.rb', line 97

def set_menu_item_string_by_pos(handle, index, string)
  validate(handle)
  AMS::C.set_menu_item_string_by_pos(handle, index.to_i, string.to_s.unpack('U*').pack('C*'))
end

+ (void) validate(handle)

This method returns an undefined value.

Verify that handle is a reference to a valid menu.

Parameters:

  • handle (Fixnum)

Raises:

  • (TypeError)

    if handle is not a reference to the valid menu.

Since:

  • 2.0.0



9
10
11
12
13
# File 'menu.rb', line 9

def validate(handle)
  AMS.validate_type(handle, Fixnum)
  return if AMS::C.is_menu?(handle)
  raise TypeError, "Handle is not a reference to a valid menu!", caller
end