How to restrict text input in hex number range?

Making a GUI for users to input hex numbers. How can I prevent input letter(s) not in the hex number range? like instead ABCD, FFFF, what if some one typing in KKKK, WXYZ? Is there any matlab input filter to reject that?

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 5 月 25 日

0 投票

If you are using a uicontrol('Style','edit'), then you can set its keypressfcn callback, which would allow you access to every key as it was pressed.
Caution: the String value of the edit box will not be the full accumulated set of characters when you access it within the keypressfcn ! (We don't know why... that's just the way it is.) You will need to store the keys away and then transfered the stored keys into the String property when the Callback function is finally triggered.

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

タグ

質問済み:

2012 年 5 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by