|
|
@@ -100,6 +100,16 @@ class _CalculatorPageState extends State<CalculatorPage> {
|
|
|
|
|
|
// ------------------------------------------------------------------ 选区操作
|
|
|
|
|
|
+ /// 操作栏上的图标按钮。压扁一点,别把这条栏撑高。
|
|
|
+ Widget _barButton(IconData icon, String tip, VoidCallback onTap) => IconButton(
|
|
|
+ tooltip: tip,
|
|
|
+ icon: Icon(icon, size: 20),
|
|
|
+ visualDensity: VisualDensity.compact,
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 6),
|
|
|
+ constraints: const BoxConstraints(minWidth: 36, minHeight: 36),
|
|
|
+ onPressed: onTap,
|
|
|
+ );
|
|
|
+
|
|
|
Future<void> _copySelection() async {
|
|
|
final t = _doc.selectionText;
|
|
|
if (t.isEmpty) return;
|
|
|
@@ -119,14 +129,6 @@ class _CalculatorPageState extends State<CalculatorPage> {
|
|
|
_snack('已剪切:$t');
|
|
|
}
|
|
|
|
|
|
- void _deleteSelection() {
|
|
|
- setState(() {
|
|
|
- _doc.deleteSelection();
|
|
|
- _pastePrompt = false;
|
|
|
- });
|
|
|
- _onDocChanged();
|
|
|
- }
|
|
|
-
|
|
|
void _dismissBar() {
|
|
|
setState(() {
|
|
|
_pastePrompt = false;
|
|
|
@@ -155,17 +157,13 @@ class _CalculatorPageState extends State<CalculatorPage> {
|
|
|
style: const TextStyle(fontFamily: 'monospace', fontSize: 12),
|
|
|
),
|
|
|
),
|
|
|
+ // 用图标而不是文字按钮 —— 文字太占地方,一条栏塞不下几个
|
|
|
if (hasSel) ...[
|
|
|
- TextButton(onPressed: _copySelection, child: const Text('复制')),
|
|
|
- TextButton(onPressed: _cutSelection, child: const Text('剪切')),
|
|
|
- TextButton(onPressed: _deleteSelection, child: const Text('删除')),
|
|
|
+ _barButton(Icons.copy, '复制', _copySelection),
|
|
|
+ _barButton(Icons.cut, '剪切', _cutSelection),
|
|
|
] else
|
|
|
- TextButton(onPressed: _paste, child: const Text('粘贴')),
|
|
|
- IconButton(
|
|
|
- tooltip: '关闭',
|
|
|
- icon: const Icon(Icons.close, size: 18),
|
|
|
- onPressed: _dismissBar,
|
|
|
- ),
|
|
|
+ _barButton(Icons.paste, '粘贴', _paste),
|
|
|
+ _barButton(Icons.close, '取消选择', _dismissBar),
|
|
|
],
|
|
|
),
|
|
|
),
|