StackOverflowMATLABchat / mlapptools

MATLAB class containing methods for programmatic uifigure modification
http://undocumentedmatlab.com/blog/customizing-uifigures-part-2
MIT License
25 stars 11 forks source link

Add support for controls whose parent is not the uifigure. #5

Closed davidn-IA closed 6 years ago

davidn-IA commented 6 years ago

This allows, for example, a text area inside a panel, to have the text formatted with bold face font. Previously this caused an error.

f = uifigure('Position', [680 558 560 420]); p = uipanel(f,'Position',[20 20 520 380]); txa = uitextarea(p, ... 'Value', 'Lorem ipsum', ... 'Position',[20 20 480 340]); mlapptools.fontWeight(txa, 'bold');

sco1 commented 6 years ago

Thanks for the catch, we haven't looked too much at UI elements that aren't direct children of the UIFigure object.

I would prefer to use ancestor if you'd like to update & repoint the PR with something like the following instead:

function [win] = getWebWindow(hUIObj)
    hUIFig = ancestor(hUIObj, 'figure');

If not, I can add & push sometime this afternoon.

altmany commented 6 years ago

Hi @davidn-IA, nice to see you here :-)

I think it would be better to leave the existing code as-is (i.e., a simple call to mlapptools.getWebWindow) and simply modify getWebWindow() to look not at the input arg directly but rather its figure ancestor (along the lines of what @sco1 just commented above)

sco1 commented 6 years ago

Thanks @altmany, that makes more sense. I forgot that there are multiple calls to getWebWindow so it's smarter to fix there :)

I've updated my comment above.

davidn-IA commented 6 years ago

Did not realize ancestor worked with uifigure, thanks @sco1. @altmany , it's about time I give something back. :-)

So maybe close this and re-post as an issue to fix getWebWindow? (also please see the other issue I posted, thanks!)

Dev-iL commented 6 years ago

@davidn-IA Feel free to add another commit to this PR to save time. When merging we'll just squash :)

sco1 commented 6 years ago

Fix has been implemented & pushed with 88b82f6 (fat-fingered the commit message reference)

This can be closed, thanks again for spotting the issue!