Disable single mouse click event for list box.

Discussion in 'Cadence' started by Hon Seng Phuah, Apr 13, 2004.

  1. I would like to know whether there is an option for me to disable the
    single mouse click in hiCreateListBoxField.

    For example, if a user clicks one's mouse (once only), the list box
    shall not change the highlight if the list box has any selection. If
    not selection prior to the single mouse click, no change is needed.

    If the user double click one mouse, the list box should highlight the
    user selection.

    -HS Phuah
     
    Hon Seng Phuah, Apr 13, 2004
    #1
  2. Hi HS,

    This doesn't really sound like a good idea to me, because it will be a rather counterintuitive
    behaviour - different from every other UI.

    You can effectively do it by having a callback on the change of value, to stop it
    being changed - you have to do some tricks so that the double click will know what
    value you want to change it to.

    I wrote some code to do this - when you try to click on a value, it changes it back to the
    previous value, but records the value you clicked on so that if you then do a double-click,
    it will really set it. It's a bit dirty, and I'd really recommend you don't do this!

    abListBox() is the entry function below to try this.

    Regards,

    Andrew.

    procedure(abCreateListBoxForm()
    let((listbox choices)
    choices='("one" "two" "three" "four" "five")
    listbox=hiCreateListBoxField(
    ?name 'listbox
    ?changeCB "abListBoxReset(hiGetCurrentForm())"
    ?doubleClickCB "abListBoxAcceptChoice(hiGetCurrentForm())"
    ?choices choices
    ?numRows 6
    )
    hiCreateAppForm(
    ?name 'abListBoxForm
    ?fields list(listbox)
    ?formTitle "List Box Sample"
    )
    )
    )

    procedure(abListBox()
    unless(boundp('abListBoxForm)
    abCreateListBoxForm()
    )
    hiDisplayForm(abListBoxForm)
    )

    procedure(abListBoxReset(form)
    unless(form->listbox->semaphore
    ; prevent the changeCB callback from being called whilst
    ; we are manipulating the value here
    form->listbox->semaphore=t
    ; store the value that was clicked
    form->listbox->clickedValue=form->listbox->value
    ; if the value is not the double-clicked value, reset it to that
    unless(form->listbox->value==form->listbox->doubleClickValue
    form->listbox->value=form->listbox->doubleClickValue
    )
    )
    ; reset the semaphore
    form->listbox->semaphore=nil
    )

    procedure(abListBoxAcceptChoice(form)
    ; store the value that was accepted when a double click occurred
    form->listbox->doubleClickValue=form->listbox->clickedValue
    ; and set the value
    form->listbox->value=form->listbox->doubleClickValue
    )
     
    Andrew Beckett, Apr 13, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.