Class: Fzeet::AcceleratorTable

Inherits:
Handle
  • Object
show all
Includes:
Windows::AcceleratorTableMethods
Defined in:
lib/fzeet/windows/user/Accelerator.rb

Instance Method Summary collapse

Methods included from Windows::AcceleratorTableMethods

#translate?

Constructor Details

#initialize(*args) ⇒ AcceleratorTable

Returns a new instance of AcceleratorTable.



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/fzeet/windows/user/Accelerator.rb', line 190

def initialize(*args)
  FFI::MemoryPointer.new(Windows::ACCEL, args.size) { |paccels|
    args.each_with_index { |data, i|
      accel = Windows::ACCEL.new(paccels + i * Windows::ACCEL.size)

      data.unshift(0) if data.size == 2

      accel[:fVirt] = Fzeet.flags(data[0], :f)

      accel[:key] = case key = data[1]
      when Integer
        accel[:fVirt] |= Windows::FVIRTKEY

        key
      when Symbol
        accel[:fVirt] |= Windows::FVIRTKEY

        ((key = key.to_s).length == 1) ? key.upcase.ord : Fzeet.constant(key, :vk_)
      when String
        if key.length == 1
          key.ord
        else
          accel[:fVirt] |= Windows::FVIRTKEY

          Fzeet.constant(key, :vk_)
        end
      end

      accel[:cmd] = Command[data[2]]
    }

    @handle = Windows.DetonateLastError(FFI::Pointer::NULL, :CreateAcceleratorTable, paccels, args.size); attach
  }
end

Instance Method Details

#disposeObject



225
# File 'lib/fzeet/windows/user/Accelerator.rb', line 225

def dispose; Windows.DestroyAcceleratorTable(@handle); detach end