I try to implement an Combo Box that Suggests Options.
Eg: if I enters "ES" in the symbol box, only those items that have ES somewhere
in their name will show
up, like ESCAPE, TEST.
But the implemented ComboBox doesn't show dropdow list,
show user must click on button of ComboBox to show it.

Source:

import Graphics.UI.WX
import Graphics.UI.WXCore
import Graphics.UI.WX.Events
import Data.List
symbols =
["ESH11","VIETTEL","METFONE","VIETNET","MENFONE","HUNET"]

--filter item in the symbols list
searchString :: String -> String -> String
searchString strInput strRaw = do
                          if strInput `isInfixOf` strRaw then
                              strRaw
                           else
                              ""

dataManager :: IO ()
dataManager = do
  frmDataManager <- frame [text:= "Data Manager"]
  cbbSymbols <- comboBoxEx frmDataManager wxCB_DROPDOWN [visible := True]
  set cbbSymbols [items := symbols, on keyboard:= cbbKeypresss cbbSymbols]
  where 
    cbbKeypresss cbb keyEvent = do --filter text when user enter text on 
comboBox
                        case (keyKey keyEvent) of
                           KeyUp -> propagateEvent
                           KeyDown -> propagateEvent
                           KeyBack -> do 
                              propagateEvent
                           other -> do
                              showText cbb (showKey (keyKey keyEvent))
                          where
                            showText cbb nextText = do
                               txt <- (get cbb text)
                               numItem <-(get cbb itemCount)
                               comboBoxRemove cbb 0 (numItem -1);
                               set cbb [text := ""]
                               set cbb [text :=txt ++ nextText]
                               txt <- (get cbb text)
                               let notNull x = not (null x) in mapM_
(comboBoxAppend cbb) ( filter notNull (map (searchString txt) symbols)) 

Could anyone help me a document about this?


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users

Reply via email to