The Accidental Rubyist

invalid byte sequence in UTF-8

class PopupList

leave a comment »

Just added a popuplist. This widget pops up a window with a scrollable list of options.
This is like a popup menu. I made this on way to making a combo-box.

This is working, but is work-in-progress.

popup menu

popup menu

In the example below, when the cursor enters the field “User”, a popup is displayed. On pressing Enter, the value populates the field User.


      field.bind(:ENTER) do |f|
        listconfig = {'bgcolor' => 'blue', 'color' => 'white'}
        url_list= %w[john tim lee wong rahul edward _why chad andy]
        pl = RubyCurses::PopupList.new do
          row  4
          col  10
          width 30
          list url_list
          list_select_mode 'single'
          relative_to f
          list_config listconfig
          bind :PRESS do |index|
            field.set_buffer url_list[index]
          end
        end
      end
 

The hash in the second line is optional, and demonstrates the listbox being configured.
relative_to allows the popup to determine the absolute position based on with field widgets absolute position. This may be improved soon.

I am currently having a close look at the online documentation of QT (link) to see its methods and events, to improve upon this library. I have had a look at the shoes manual yesterday, the TK tutorials here.. If readers feel this library could benefit by getting ideas from some other widget/UI library, please give me an online link to the docs. I also keep checking my O Reilly Java Swing book for ideas.

Looking forward to feedback.

Advertisements

Written by totalrecall

December 11, 2008 at 10:50 pm

Posted in ncurses, rbcurse, ruby

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: