Apparently the text portion of a ComboBox does not allow the user to enter
more characters than can be displayed. I have found that the same issue exists with a TextEdit, and one can fix this by setting canHScroll to true. I decided to be creative and try: "editView canHScroll: true", but alas this does not work quite as I had hopped. See the code example bellow. ============ "Create a small combo box." cb := ComboBox show. cb model: (ListModel on: #('Cat' 'Dog' 'Mouse')). cb extent: 50@100. "Try typing something longer than its width, it won't let you." "If one evaluates the line bellow it works, but adds a border, and seems to disassociate the TextEdit from the ComboBox." cb editView canHScroll: true. "Evaluating this seems to prove it has been disassociated." cb editView. ============ I can get editView to return the TextEdit again if I change its id back to 1001. However it still does not behave like a proper ComboBox if a selection is made from the list, the text from the list never gets into the real TextEdit. I suspect that the problem is it is destroyed and recreated when the style is changed, and that disassociates it from the ComboBox. Has anyone else had to overcome this yet? Any pointers? Chris |
Chris,
> Has anyone else had to overcome this yet? Any pointers? Go to ComboBox>>defaultWindowStyle and append the constant CBS_AUTOHSCROLL to the list. That should allow h scrolling in the combos edit field. You will still be limited (if MSDN is correct) to a maximum 30000 characters - I can't say I've tested that though :-) If you want a smaller limit you can send a CB_LIMITTEXT message to the ComboBox but you will have to add a wrapper to Dolphin. -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
> You will still be limited (if MSDN is correct) to a maximum 30000
> characters - I can't say I've tested that though :-) Ooops, my mistake. 30000 is just the default. You can set the edit field to accept up to 2147483646 characters - but I haven't tested that either :-) -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
In reply to this post by Christopher J. Demers
"Christopher J. Demers" <[hidden email]> wrote in
message news:brtofs$78soc$[hidden email]... > Apparently the text portion of a ComboBox does not allow the user to enter > more characters than can be displayed. I have found that the same issue > exists with a TextEdit, and one can fix this by setting canHScroll to true. > I decided to be creative and try: "editView canHScroll: true", but alas this > does not work quite as I had hopped. See the code example bellow. > ... > I can get editView to return the TextEdit again if I change its id back to > 1001. However it still does not behave like a proper ComboBox if a > selection is made from the list, the text from the list never gets into the > real TextEdit. I suspect that the problem is it is destroyed and recreated > when the style is changed, and that disassociates it from the ComboBox. > Has anyone else had to overcome this yet? Any pointers? Yes, that would be the case. If you look at TextEdit>>canHScroll: you will see that it is implemented in terms of View>>baseStyleMask:set:, and the implementation of that is: self baseStyleMask: anInteger set: aBoolean recreateIfChanged: true i.e. the view will be recreated if the style is changed. By default we recreate views when a style is changed as quite a lot of Window styles cannot be changed once a window has been created. Normally this recreation is transparent since the MVP framework will reinstate everything as it was before. However recreating views that are not owned by Dolphin (such as the edit box belonging to a combobox) is likely to break things. Actually this is why the Visual Object Finder's option to find external views is turned off by default - you can use it to inspect the style settings,etc, of windows in other applications, but if you change anything the other application will be toast. In some cases we have taken the time to investigate whether recreation is necessary, and you will see that the style modification method passes 'false' for the recreateIfChanged parameter. I can't remember whether we did in this case (although the comment in MultilineTextEdit>>canHScroll: would suggest we did), but taking a quick look now changing the style after view recreation doesn't seem to have any effect, so recreating the edit control when the style is changed would appear to be the only option. You can try it yourself by inlining the send of #baseStyleMask:set: in TextEdit>>canHScroll: and inverting the boolean argument. Don't worry, though, there is a solution. We just need to extend ComboBox itself to include a #canHScroll property like TextEdit's, since there is a ComboBox style CBS_AUTOHSCROLL that corresponds to the Edit style ES_AUTOHSCROLL. I've attached the code below. This enhancement will be included in the next patch level. Regards Blair -------------------------- "#1460"! !ComboBox methodsFor! canHScroll "Answer whether the receiver's edit field is in horizontal scrolling mode." ^self baseStyleAllMask: CBS_AUTOHSCROLL! ! !ComboBox categoriesFor: #canHScroll!accessing-styles!public! ! !ComboBox methodsFor! canHScroll: aBoolean "Sets the receiver into horizontal scrolling mode if aBoolean is true. When this style is off the control limits the amount of text that can be entered to that which can be displayed in the box. When the style is on the user can enter more text than can be displayed (the caret remains at the right edge of the field and the text scrolls left to accomodate new input)." "Implementation Note: The control ignores changes to this style after creation, so we must accept the default action, which is to recreate the view." self baseStyleMask: CBS_AUTOHSCROLL set: aBoolean! ! !ComboBox categoriesFor: #canHScroll:!accessing-styles!public! ! !ComboBox class methodsFor! publishedAspectsOfInstances "Answer a <LookupTable> of the <Aspect>s published by instances of the receiver." ^(super publishedAspectsOfInstances) add: (Aspect integer: #droppedHeight); add: (Aspect choice: #mode from: Modes); add: (Aspect boolean: #canHScroll); yourself! ! !ComboBox class categoriesFor: #publishedAspectsOfInstances!constants!development!public! ! |
Blair,
> Don't worry, though, there is a solution. We just need to extend > ComboBox itself to include a #canHScroll property like TextEdit's, > since there is a ComboBox style CBS_AUTOHSCROLL that corresponds to > the Edit style ES_AUTOHSCROLL. I've attached the code below. This > enhancement will be included in the next patch level. As you are going to modify this I was wondering if you could also add similar support for the CBS_SORT and LBS_SORT styles. This automatically sorts the contents of ComboBoxes and ListBoxes and it would remove the need to do any sorting of the underlying Collection or Model which can, sometimes, cause problems. I hadn't noticed this style before and looks quite useful. -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
> As you are going to modify this I was wondering if you could also add
> similar support for the CBS_SORT and LBS_SORT styles. On further reflection - don't bother. I see the problems it causes :-( I'll shut up now and go back to sleep :-) -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
In reply to this post by Ian Bartholomew-18
> As you are going to modify this I was wondering if you could also add
> similar support for the CBS_SORT and LBS_SORT styles. On further reflection - don't bother. I see the problems it causes :-( I'll shut up now and go back to sleep :-) -- Ian |
In reply to this post by Ian Bartholomew-18
"Ian Bartholomew" <[hidden email]> wrote in message
news:brun8b$7qjcq$[hidden email]... > > > As you are going to modify this I was wondering if you could also add > > similar support for the CBS_SORT and LBS_SORT styles. > > On further reflection - don't bother. I see the problems it causes :-( Indeed :-). Regards Blair |
In reply to this post by Ian Bartholomew-18
"Ian Bartholomew" <[hidden email]> wrote in message
news:MYzEb.2742$[hidden email]... > > Has anyone else had to overcome this yet? Any pointers? > > Go to ComboBox>>defaultWindowStyle and append the constant > CBS_AUTOHSCROLL to the list. That should allow h scrolling in the > combos edit field. > > You will still be limited (if MSDN is correct) to a maximum 30000 > characters - I can't say I've tested that though :-) If you want a > smaller limit you can send a CB_LIMITTEXT message to the ComboBox but > you will have to add a wrapper to Dolphin. Thanks Ian, it looks like that would work. But it looks like Blair's patch obviates the issue for me, so I will just go with that. I am really glad to see you posting here again. You have been missed. I am a bit of a c.l.s.d addict, so the more high quality posts here the more entertained I feel. ;) Chris |
In reply to this post by Blair McGlashan
"Blair McGlashan" <[hidden email]> wrote in message
news:bruini$7j6pa$[hidden email]... > "Christopher J. Demers" <[hidden email]> wrote in > message news:brtofs$78soc$[hidden email]... > > Apparently the text portion of a ComboBox does not allow the user to enter > > more characters than can be displayed. I have found that the same issue ... > Don't worry, though, there is a solution. We just need to extend ComboBox > itself to include a #canHScroll property like TextEdit's, since there is a > ComboBox style CBS_AUTOHSCROLL that corresponds to the Edit style > ES_AUTOHSCROLL. I've attached the code below. This enhancement will be > included in the next patch level. ... Excellent, as always, that does exactly what I need. Thank you. Chris |
In reply to this post by Christopher J. Demers
Chris,
> Thanks Ian, it looks like that would work. But it looks like Blair's > patch obviates the issue for me, so I will just go with that. Oh sure. They both do essentially the same thing but Blair's patch gives you the choice when you create the view, mine insists you allow it all the time ;-) No contest. > I am > really glad to see you posting here again. You have been missed. I > am a bit of a c.l.s.d addict, so the more high quality posts here the > more entertained I feel. ;) Thanks. I'm not so sure about the "high quality" bit but I do try, honestly :-) -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
Free forum by Nabble | Edit this page |