Jump to content

Combobox button height


Tim

Recommended Posts

Hi,

 

I know this question has been asked a couple of times before, but we have the problem that we would like to increase the height of a TUniComboBox beyond the 22 pixel default. Unfortunately this results in the ungainly appearance shown in the attached image, where the height of the button part of the combobox no longer matches that of the editor part.

 

I was just wondering if anyone has come up with a workaround for this? Maybe one could hide the button part and put a TUniButton in its place which causes the list to drop down when clicked?

 

Many thanks

Tim

post-2020-0-29314700-1423620572_thumb.png

Link to comment
Share on other sites

I was just wondering if anyone has come up with a workaround for this? Maybe one could hide the button part and put a TUniButton in its place which causes the list to drop down when clicked?

 

 

Hi,

 

You can...  :)

 

For example:

 

1. UniComboBox1 -> ClientEvents -> UniEvents

function beforeInit(sender, config)
{
  sender.hideTrigger = true;
  //sender.isExpanded = false;
}

2.

procedure TMainForm.UniButton1Click(Sender: TObject);
begin  
  UniSession.AddJS('MainForm.UniComboBox1.expand()');
end;

But this is a quick, rough workaround!

 

Try..

 

Best regards.

Link to comment
Share on other sites

Hi,

 

I just noticed that the reply that was posted here yesterday has been removed. Was there something wrong with the information it contained? Should i not use that code? It worked just fine in my tests :)

 

Thanks,

Tim

Link to comment
Share on other sites

Hi,

 

I just noticed that the reply that was posted here yesterday has been removed. Was there something wrong with the information it contained? Should i not use that code? It worked just fine in my tests :)

 

Thanks,

Tim

 

Hi,

 

Sorry, Now again displayed! :)

 

Best regards.

Link to comment
Share on other sites

Thanks! For what it's worth, i have attached an example of using this technique in the main form of a project. For a convincing implementation one would probably want to create a glyph for the TUniSpeedButton which looks as close as possible to a normal combobox button. To allow the combobox to toggle between the expanded and collapsed state when the button is repeatedly clicked, i record the time of the most recent combobox collapse event. In the button click event, i compare this recorded time to the current time; if the difference is <= 100 milliseconds, the combobox was probably already expanded when the button was clicked so i close it. One could probably improve on this implementation. Anyway, maybe this example will help someone :)

ComboBox.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...